ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#205938 | #883. 求先序排列 | wsh0220 | 100 | 0ms | 1212kb | C++ | 381b | 2024-07-20 18:02:05 | 2024-07-20 20:04:17 |
answer
#include<bits/stdc++.h>
using namespace std;
void dfs(string x,string after)
{
if (x.size()>0)
{
char h=after[after.size()-1];
cout<<h;
int k=x.find(h);
dfs(x.substr(0,k),after.substr(0,k));
dfs(x.substr(k+1),after.substr(k,x.size()-k-1));
}
}
string a,b;
int main()
{
cin>>a>>b;
dfs(a,b);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 20
Accepted
time: 0ms
memory: 1208kb
input:
ACEB AEBC
output:
CABE
result:
ok single line: 'CABE'
Test #2:
score: 20
Accepted
time: 0ms
memory: 1212kb
input:
BAC BCA
output:
ABC
result:
ok single line: 'ABC'
Test #3:
score: 20
Accepted
time: 0ms
memory: 1212kb
input:
DEABFCHG DEAFHGCB
output:
BAEDCFGH
result:
ok single line: 'BAEDCFGH'
Test #4:
score: 20
Accepted
time: 0ms
memory: 1212kb
input:
DCBA DCBA
output:
ABCD
result:
ok single line: 'ABCD'
Test #5:
score: 20
Accepted
time: 0ms
memory: 1212kb
input:
CBAFEGD CFGEADB
output:
BCDAEFG
result:
ok single line: 'BCDAEFG'