update
This commit is contained in:
		
							parent
							
								
									6731e1f80c
								
							
						
					
					
						commit
						8bf3ffc888
					
				
							
								
								
									
										39
									
								
								src/P1087/P1087.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/P1087/P1087.cpp
									
									
									
									
									
										Normal 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());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user