MLE*4,20pts求助
查看原帖
MLE*4,20pts求助
491007
凤凰工作室楼主2023/5/8 19:53

不知道哪里 MLE 了

#include<bits/stdc++.h>
using namespace std;
int toint(char c)
{
    return c-'A'+1;
}
struct node
{
    int a,b;
}ps[35];
string a,b;
string work(int l,int r)
{
    if(l==r)
    {
        string t="1";
        t[0]=a[l];
        return t;
    }
    int k=ps[toint(b[r])].a;
    return a[k]+work(l,k-1)+work(k+1,r);
}
int main(void)
{
    cin>>a>>b;
    for(int i=0;i<a.length();i++)
    {
        ps[toint(a[i])].a=i;
        ps[toint(b[i])].b=i;
    }
    cout<<work(0,a.length()-1);
}
2023/5/8 19:53
加载中...