㊗️:☀️☃️☃️☃️☀️ • 4个月前
#include<iostream>
using namespace std;
string s;
char hasType(int left,int right) {
bool hasZero=false, hasOne = false;
for (int i = left; i <= right; i++) {
if (s[i] == '0') hasZero = true;
else if (s[i] == '1')hasOne = true;
if (hasZero && hasOne) return 'F';
}
if (hasZero)return 'B';
return 'I';
}
void maketree(int left, int right) {
if (left != right) {
int mid = (left + right) / 2;
maketree(left, mid);
maketree(mid + 1, right);
}
cout << hasType(left, right);
}
int main() {
int n;
cin >> n;
cin >> s;
maketree(0,s.size()-1);
return 0;
}
评论:
请先登录,才能进行评论