AC

 •  1个月前


#include <bits/stdc++.h>
using namespace std;

string buildFBI(string s) {

	bool has0 = (s.find('0') != string::npos);
	bool has1 = (s.find('1') != string::npos);
	char type;
	if (has0 && has1)
		type = 'F';
	else if (has0)
		type = 'B';
	else
		type = 'I';
	if (s.size() == 1) {
		return string(1, type);
	}
	int mid = s.size() / 2;
	string left = s.substr(0, mid);
	string right = s.substr(mid);
	return buildFBI(left) + buildFBI(right) + type;
}

int main() {
	int N;
	string s;
	cin >> N >> s;
	cout << buildFBI(s) << endl;
	return 0;
}

评论:

请先登录,才能进行评论