algorithm_2024/src/P1087/P1087.cpp
2024-10-14 19:22:27 +08:00

39 lines
643 B
C++

#include <iostream>
#include <string>
using ll = long long;
auto &is = std::cin;
auto &os = std::cout;
// const ll max_n = 10+2;
ll _;
std::string s;
void dfs(const ll start, const ll end)noexcept{
if(start < end-1){
const ll mid {(start+end)/2};
dfs(start,mid);
dfs(mid,end);
}
bool is_not_B = false,is_not_I = false;
for(ll i{start};i!=end;i++){
if(s[i]!='0')is_not_B=true;
if(s[i]!='1')is_not_I=true;
}
if(!is_not_B){
os<<'B';
}else if(!is_not_I){
os<<'I';
}else{
os<<'F';
}
}
int main(){
is>>_;
is>>s;
dfs(0,s.size());
}