文章
17
粉丝
166
获赞
6
访问
144.5k
#include <bits/stdc++.h>
using namespace std;
vector<char> pre, in, post;
int cnt = 0;
string a,b;
void recons(int l, int r)
{
if(l >= r) return;
char root = pre[cnt++];
int m = distance(in.begin(), find(in.begin(), in.end(), root));
recons(l, m);
recons(m + 1, r);
post.push_back(root);
}
int main()
{
cin >> a >> b;
for(int i = 0; i < a.size(); i++)
{
pre.push_back(a[i]);
in.push_back(b[i]);
}
recons(0, a.size());
for(int i = 0; i < a.size(); i++)
cout << post[i];
return 0;
}
登录后发布评论
暂无评论,来抢沙发