hdu_1030 求先序排列

#include<bits/stdc++.h>
using namespace std;
string a,b;
int n;
void dfs(int l,int r){
int now=0;
for(int i=n-1;i>=0;i--)if(!now)
for(int j=l;j<=r;j++)if(b[i]==a[j]){now=j; break;}
putchar(a[now]);
if(now-1>=l)dfs(l,now-1);
if(now+1<=r)dfs(now+1,r);
}
int main(){
cin>>a>>b;
n=a.size();
dfs(0,n-1);
puts("");
return 0;
}
原文地址:https://www.cnblogs.com/codetogether/p/7501849.html