2叉树,后续遍历
#include<iostream>
using namespace std;
string ans;
int n;
void build(int l,int r)
{
int mid=(r+l)/2;
if(l!=r)
{
build(l,mid);
build(mid+1,r);
}
int num0=0,num1=0;
for(int i=l;i<=r;i++)
{
if(ans[i]=='0') num0++;
else num1++;
}
if(r-l+1==num0) cout<<'B';
else if(r-l+1==num1) cout<<'I';
else cout<<'F';
}
int main()
{
while(cin>>n>>ans)
{
n=1<<n;
build(0,n⑴);
cout<<endl;
}
return 0;
}