RE 90分求助
查看原帖
RE 90分求助
566935
timmark楼主2022/8/9 10:23

rt,求助各位大佬

#include<bits/stdc++.h>
using namespace std;
int n;
char tree[4010],s[2048];
void PostOrder(int root){
	if(tree[2*root]) PostOrder(2*root);
	if(tree[2*root+1]) PostOrder(2*root+1);
	printf("%c",tree[root]);
}char merge(char a,char b){
	if(a!=b) return 'F';
	if(a==b) return a;
}int main(){
	scanf("%d\n%s",&n,s);
	n=( 1 << n );
	for(int i=0;i<n;i++) tree[i+n]=( int(s[i]-'0') ? 'I' : 'B' );
	for(int i=n-1;i>0;i--) tree[i]=merge(tree[2*i],tree[2*i+1]);
	PostOrder(1);
	return 0;
}
2022/8/9 10:23
加载中...