'commit'
This commit is contained in:
33
TangDou/CSP-J/AcWingTraining/T8/419_2.cpp
Normal file
33
TangDou/CSP-J/AcWingTraining/T8/419_2.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
string str;
|
||||
|
||||
void dfs(int L, int R) {
|
||||
if (R > L) {
|
||||
int mid = L + R >> 1;
|
||||
dfs(L, mid); // 左子树
|
||||
dfs(mid + 1, R); // 右子树
|
||||
}
|
||||
// 我该输出啥?
|
||||
int one = 0, zero = 0;
|
||||
for (int i = L; i <= R; i++)
|
||||
if (str[i] == '0')
|
||||
zero++;
|
||||
else
|
||||
one++;
|
||||
|
||||
if (one && zero)
|
||||
cout << 'F';
|
||||
else if (one)
|
||||
cout << 'I';
|
||||
else
|
||||
cout << 'B';
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n >> str;
|
||||
dfs(0, str.size() - 1);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user