1 solutions

  • 0
    @ 2025-8-1 11:24:16
    #include<bits/stdc++.h>
    using namespace std;
    string sz,sh;
    void dfs(int l1,int r1,int l2,int r2)
    {
    	if(l1>r1)
    	{
    		return;
    	}
    	cout<<sh[r2];
    	int m=sz.find(sh[r2]);
    	if(m>l1)
    	{
    		dfs(l1,m-1,l2,l2+m-l1-1);
    	}
    	if(m<r1)
    	{
    		dfs(m+1,r1,l2+m-l1,r2-1);
    	}
    }
    int main()
    {
    	cin>>sz>>sh;
    	int n=sh.size();
    	dfs(0,n-1,0,n-1);
    	return 0;
    }
    
    
    

    Information

    ID
    264
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    14
    Accepted
    4
    Uploaded By