problem
solution
codes
#include<stdio.h>
#define maxn 1<<12
using namespace std;
struct node{
char t;
int l, r;
node():t('*'),l(0),r(0){}
}tree[maxn];
char s[maxn];
int top = -1;
char check(int le, int ri){
int l=0, b=0;
for(int i = le; i <= ri; i++){
if(s[i]=='1')l=1;
if(s[i]=='0')b=1;
}
if(l==1&&b==1)return 'F';
if(l)return 'I';
if(b)return 'B';
}
int build(int l, int r){
if(l >= r){
tree[++top].t = check(l,r);
return top;
}
tree[++top].t = check(l,r);
int now = top;
int root = (l+r)/2;
tree[now].l = build(l,root);
tree[now].r = build(root+1,r);
return now;
}
void dfs(int root){
if(tree[root].l)dfs(tree[root].l);
if(tree[root].r)dfs(tree[root].r);
printf("%c",tree[root].t);
}
int main(){
int n; scanf("%d%s",&n,s+1);
n = 1<<n;
build(1,n);
dfs(0);
return 0;
}