提交时间:2023-08-23 16:00:09
运行 ID: 99702
#include <bits/stdc++.h> using namespace std; string a, b; void dfs(int a1, int a2, int b1, int b2) { if (a1 > a2 || b1 > b2) { // JUMP TO A NULL NOSW return; } // cout << a1 << " " << a2 << " " << b1 << " " << b2 << endl; if (a1 == a2) { cout << a[a1]; return; } char mid = a[a2]; int midp; for (int i = b1; i <= b2; i++) { if (b[i] == mid) { midp = i; break; } } cout << mid; dfs(a1, a1 + (midp - b1 - 1), b1, midp - 1); dfs(a1 + (midp - b1), a2-1, midp + 1, b2); } int main() { cin >> a >> b; dfs(0, a.size()-1, 0, b.size()-1); return 0; }