ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#205987 | #883. 求先序排列 | Xieyunlong | 100 | 0ms | 1148kb | C++ | 339b | 2024-07-20 18:36:50 | 2024-07-20 20:12:25 |
answer
#include <bits/stdc++.h>
using namespace std;
char a[10],b[10];
void dfs(int la,int ra,int lb,int rb){
if(la>ra) return ;
cout<<b[rb];
int p=la,cnt=0;
while (a[p]!=b[rb]) p++;
cnt=p-la;
dfs(la,p-1,lb,lb+cnt-1);
dfs(p+1,ra,lb+cnt,rb-1);
}
int main(){
cin>>a>>b;
int len=strlen(a)-1;
dfs(0,len,0,len);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 20
Accepted
time: 0ms
memory: 1148kb
input:
ACEB AEBC
output:
CABE
result:
ok single line: 'CABE'
Test #2:
score: 20
Accepted
time: 0ms
memory: 1144kb
input:
BAC BCA
output:
ABC
result:
ok single line: 'ABC'
Test #3:
score: 20
Accepted
time: 0ms
memory: 1144kb
input:
DEABFCHG DEAFHGCB
output:
BAEDCFGH
result:
ok single line: 'BAEDCFGH'
Test #4:
score: 20
Accepted
time: 0ms
memory: 1144kb
input:
DCBA DCBA
output:
ABCD
result:
ok single line: 'ABCD'
Test #5:
score: 20
Accepted
time: 0ms
memory: 1148kb
input:
CBAFEGD CFGEADB
output:
BCDAEFG
result:
ok single line: 'BCDAEFG'