0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 07:38:49 +00:00

P1030 [NOIP2001 普及组] 求先序排列

R44267392
This commit is contained in:
Baoshuo Ren 2020-12-26 19:38:13 +08:00 committed by Baoshuo Ren
parent 7f8bfbd3a1
commit 0ede4b6a2d
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

22
problem/P1030/P1030.cpp Normal file
View File

@ -0,0 +1,22 @@
#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;
}