This commit is contained in:
Zengtudor 2024-10-14 19:22:27 +08:00
parent 6731e1f80c
commit 8bf3ffc888

39
src/P1087/P1087.cpp Normal file
View File

@ -0,0 +1,39 @@
#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());
}