#include <cstring>#include <cstdio>#include <iostream>using namespace std;#define max(a,b) ((a>b)?(a):(b))int s[2000]={0};struct Node{bool have_value;char v;Node *left,*right;Node():have_value(false),left(NULL),right(NULL){};};Node *newNode(){return new Node();}void addNode(Node *root,int top,int bottom){int sum=0;for(int i=top;i<=bottom;i++)sum+=s[i];if(sum==bottom-top+1) {root->v='I';}else if(sum==0) {root->v='B';}else {root->v='F';}root->have_value=true;if(top<bottom){root->left=newNode();root->right=newNode();addNode(root->left,top,(top+bottom)/2);addNode(root->right,(top+bottom)/2+1,bottom);}else{root->left=NULL;root->right=NULL;}}void postOrder(Node *root){if(root==NULL)return;postOrder(root->left);postOrder(root->right);PRintf("%c",root->v);}int main(){int i=1,N;char c;Node *root;scanf("%d",&N);getchar();while((c=getchar())!='/n')s[i++]=c-'0';root=newNode();addNode(root,1,i-1);postOrder(root);return 0;}
新闻热点
疑难解答