AC

❤ · 发布于 2025-08-16 · 浏览 349 回复 0
#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;
}

全部回复 共 0 条

还没有人回复。往下写第一条。

发表回复