只过13 40pts求助
查看原帖
只过13 40pts求助
1111300
ayszYW楼主2024/7/16 09:34

rt

#include<bits/stdc++.h>
using namespace std;


char s1[15],s2[15],s3[15];
int v[10];
struct Cy{
	int a,b;
	char v;
}tr[10];

void build(int l,int r,int c){
	if(v[l]==1||v[r]==1)return;
	
	int root=(l+r+1)/2;
//	cout<<c;
//	cout<<l<<" "<<r<<" "<<root<<endl;
	//cout<<root;
	v[root]=1;
	tr[c].b=r;
	tr[c].a=l;
	tr[c].v=s1[root];
	
	if(l==r){
		return;
	}
	
	if(root-1>=l)build(l,root-1,2*c);
	if(root+1<=r)build(root+1,r,2*c+1);
	
	return;
	
}


void dfs(int c,int l){
	//cout<<c;
	if(tr[c].v==' ')return;
	cout<<tr[c].v;
	if(tr[c].a==tr[c].b)return;
	dfs(2*c,l);
	dfs(2*c+1,l);
	return;
}



int main(){
	
	cin>>s1+1>>s2+1;
	int l=strlen(s1+1);
	int root=(l+1)/2;
	//cout<<root;
	tr[1].a=1,tr[1].b=l;
	tr[1].v=s1[root];
	v[root]=1;
	if(root-1>=1)build(1,root-1,2);
	if(root+1<=l)build(root+1,l,3);
	
	
	dfs(1,l);
	
	
	
}
2024/7/16 09:34
加载中...