mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 08:58:48 +00:00
P1030 [NOIP2001 普及组] 求先序排列
R44267392
This commit is contained in:
parent
7f8bfbd3a1
commit
0ede4b6a2d
22
problem/P1030/P1030.cpp
Normal file
22
problem/P1030/P1030.cpp
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user