From 0ede4b6a2df96c3cf0243d4dd1aa1399dafa5d9a Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sat, 26 Dec 2020 19:38:13 +0800 Subject: [PATCH] =?UTF-8?q?P1030=20[NOIP2001=20=E6=99=AE=E5=8F=8A=E7=BB=84?= =?UTF-8?q?]=20=E6=B1=82=E5=85=88=E5=BA=8F=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R44267392 --- problem/P1030/P1030.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 problem/P1030/P1030.cpp diff --git a/problem/P1030/P1030.cpp b/problem/P1030/P1030.cpp new file mode 100644 index 00000000..48072740 --- /dev/null +++ b/problem/P1030/P1030.cpp @@ -0,0 +1,22 @@ +#include + +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; +}