'commit'
This commit is contained in:
33
TangDou/CSP-J/AcWingTraining/T8/419_1.cpp
Normal file
33
TangDou/CSP-J/AcWingTraining/T8/419_1.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void dfs(string str) {
|
||||
if (str.size() > 1) {
|
||||
dfs(str.substr(0, str.size() / 2)); // 左子树
|
||||
dfs(str.substr(str.size() / 2)); // 右子树
|
||||
}
|
||||
// 我该输出啥?
|
||||
int one = 0, zero = 0;
|
||||
for (int i = 0; i < str.size(); 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;
|
||||
string str;
|
||||
cin >> n >> str;
|
||||
|
||||
dfs(str);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user