代码在这
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
void postorder(int root);
#define MAXN 100000
struct tnode
{
char data;
int lc,rc;
} t[MAXN];
int main()
{
char str[2000];
int N,len,i,j;
cin>>N>>str+1;
len=strlen(str)-1;
for (i=1;i<=len;i++)
{
if (str[i]=='0') t[i].data='B';
else t[i].data='I';
t[i].lc=t[i].rc=0;
}
for(i=1,j=len+1;j<=2*len-1;i+=2,j++)
{
t[j].lc=i;
t[j].rc=i+1;
if (t[i].data==t[i+1].data) t[j].data=t[i].data;
else t[j].data='F';
}
postorder(2*len-1);
return 0;
}
void postorder(int root)
{
if (root)
{
postorder(t[root].lc);
postorder(t[root].rc);
cout<<t[root].data;
}
}