为什么只有10分?!
查看原帖
为什么只有10分?!
929192
Tx1234567楼主2023/9/18 20:01
#include <bits/stdc++.h>
using namespace std;
int n;
char ch[1<<11];
string s;
void dfs(int x){
	if (x>=1<<n){
		ch[x] = s[x-(1<<n)]=='1'?'I':'B';
		cout<<ch[x];
		return;
	}
	dfs(2*x);
	dfs(2*x+1);
	if (ch[2*x]==ch[2*x+1]){
		ch[x] = ch[2*x];
	}else{
		ch[x] = 'F';
	}
	cout<<ch[x];
}
int main(){
	cin>>n;
	getchar();
	getline(cin,s);
	dfs(1);
	return 0;
}
2023/9/18 20:01
加载中...