各位大佬帮帮看看,一直一个点wa,特判也没用,但答案又没错,服了

#include<bits/stdc++.h>
using namespace std;
string s;
int n;
char tree[5005];
char type(string s){
if(!~s.find("1"))
return 'B';
else if(!~s.find("0"))
return 'I';
else
return 'F';
}
void fenzhi(int l,int r,int x){
if(l>r||x>(1<<n+1))
return;
tree[x]=type(s.substr(l,r-l+1));
int mid=(l+r+1>>1)-1;
fenzhi(l,mid,x<<1);
fenzhi(mid+1,r,x<<1|1);
}
void houxu(int x){
if(!tree[x])
return;
houxu(x<<1);
houxu(x<<1|1);
printf("%c",tree[x]);
}
int main(){
memset(tree,'\0',sizeof(tree));
scanf("%d",&n);
getline(cin,s);
getline(cin,s);
if(n==0&&s=="0"){
printf("B");
return 0;
}
fenzhi(0,s.size()-1,1);
houxu(1);
return 0;
}