ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#206027 | #883. 求先序排列 | Caohanxuan_111213 | 100 | 1ms | 1148kb | C++11 | 404b | 2024-07-20 18:57:09 | 2024-07-20 20:18:24 |
answer
#include<bits/stdc++.h>
using namespace std;
char s1[15],s2[15];
void man(int l_1,int r_1,int l_2,int r_2){
if(l_1>r_1||l_2>r_2){
return;
}
int i;
for(i=l_1;i<=r_1;i++){
if(s1[i]==s2[r_2]){
break;
}
}
cout<<s2[r_2];
man(l_1,i-1,l_2,l_2-l_1+i-1);
man(i+1,r_1,l_2-l_1+i,r_2-1);
}
int main(){
cin>>s1>>s2;
int len=strlen(s1);
man(0,len-1,0,len-1);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 20
Accepted
time: 0ms
memory: 1144kb
input:
ACEB AEBC
output:
CABE
result:
ok single line: 'CABE'
Test #2:
score: 20
Accepted
time: 1ms
memory: 1148kb
input:
BAC BCA
output:
ABC
result:
ok single line: 'ABC'
Test #3:
score: 20
Accepted
time: 0ms
memory: 1148kb
input:
DEABFCHG DEAFHGCB
output:
BAEDCFGH
result:
ok single line: 'BAEDCFGH'
Test #4:
score: 20
Accepted
time: 0ms
memory: 1148kb
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'