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