diff --git a/src/P1087/P1087.cpp b/src/P1087/P1087.cpp new file mode 100644 index 0000000..da86347 --- /dev/null +++ b/src/P1087/P1087.cpp @@ -0,0 +1,39 @@ +#include +#include + +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()); +} \ No newline at end of file