1 solutions

  • 0
    @ 2025-11-5 19:21:32

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    void f(string a, string b) {
    	if (a.size() == 0) return;
    	
    	char root = a[0];
    	int pos = b.find(root);
    	
    	f(a.substr(1, pos), b.substr(0, pos));
    	f(a.substr(pos + 1), b.substr(pos + 1));
    	cout << root;
    }
    
    int main() {
    	string a, b;
    	while (cin >> a >> b) {
    		f(a, b);
    		cout << endl;
    	}
    
    	return 0;
    }
    
    
    • 1

    Information

    ID
    19286
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By