0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 20:16:27 +00:00
OI-codes/Luogu/P1030/P1030.cpp

23 lines
418 B
C++
Raw Normal View History

#include <bits/stdc++.h>
using namespace std;
string s1, s2, s3;
void dfs(string s1, string s2) {
if (!s1.size()) return;
char root = *--s2.end();
int k = s1.find(root);
s3.push_back(root);
dfs(s1.substr(0, k), s2.substr(0, k));
dfs(s1.substr(k + 1), s2.substr(k, s2.size() - k - 1));
return;
}
int main() {
cin >> s1 >> s2;
dfs(s1, s2);
cout << s3 << endl;
return 0;
}