T236450 美国血统
下面的是修正之后通过了的代码
#include<iostream> using namespace std; string mid,pre; void post(int index,int left,int right){ if(left>right){return;} int tmp=left; while(tmp<right&&mid[tmp]!=pre[index]){ tmp=tmp+1; } post(index+1,left,tmp-1); post(index+tmp-left+1,tmp+1,right); cout<<pre[index]; } int main(){ cin>>mid>>pre; post(0,0,mid.length()-1); return 0; }
网址 :https://www.luogu.com.cn/problem/T236450?contestId=67903