0pts求调,全RE
查看原帖
0pts求调,全RE
671925
caotianhao楼主2023/8/14 18:48
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt;
string s;
char FBI(int l,int r){
	char c=s[l];
	for(int i=l+1;i<=r;i++){
		if(s[i]!=c){
			return 'F';
		}
	}
	if(c=='1'){
		return 'I';
	}else{
		return 'B';
	}
}
struct tree{
	int f,l,r;
	char ty;
}t[2050];
void init(int l,int r){
	if(l>r){
		return ;
	}
	t[++cnt].ty=FBI(l,r);
	if(cnt!=1){
		t[cnt].f=cnt/2;
	}
	if(cnt<n){
		t[cnt].l=cnt*2;
		t[cnt].r=cnt*2+1;
	}
	int mid=(l+r)/2+1;
	init(l,mid);
	init(mid+1,r);
}
void hou(int root){
	if(root){
		hou(t[root].l);
		hou(t[root].r);
		cout<<t[root].ty;
	}
	
}
int main(){
	cin>>m>>s;
	n=pow(2,m);
	init(0,n-1);
	hou(1);
	return 0;
} 
2023/8/14 18:48
加载中...