UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#206027#883. 求先序排列Caohanxuan_1112131001ms1148kbC++11404b2024-07-20 18:57:092024-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'