1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include<bits/stdc++.h> using namespace std; string tree; int n; char get_kind(string x) { if(x.find('0')!=x.npos&&x.find('1')!=x.npos)return 'F'; else if(x.find('0')!=x.npos)return 'B'; else return 'I'; } void def(string tree) { if(tree.length()==1){cout<<get_kind(tree);return;} def(tree.substr(0,tree.length()/2)); def(tree.substr(tree.length()/2)); cout<<get_kind(tree); } int main() { cin>>n>>tree; def(tree); }
|