// UVa 536 - Tree Recovery
#include <iostream>
#include <string>
using namespace std;
string pre, in;
int i;
void build(int a, int b) {
if (a <= b) {
i++;
int c = in.find(pre[i], a);
build(a, c - 1);
build(c + 1, b);
cout << in[c];
}
}
int main() {
while (cin >> pre) {
cin >> in;
i = -1;
build(0, in.length() - 1);
cout << endl;
}
return 0;
}
No comments:
Post a Comment