题解 CF1189A 【Keanu Reeves】
很容易理解一道题目,分类讨论即可:
-
如果本身就是好序列,直接输出 与本身字符串。
-
如果不是,输出 并且输出该字符串的第一个(或者最后一个)字符然后空格,接着是后面的。
代码:
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
string s;
cin >> s >> s;
int cnt1 = count(s.begin(), s.end(), '1'), cnt0 = count(s.begin(), s.end(), '0');
if (cnt1 != cnt0)
{
cout << "1\n" << s << endl;
}
else
{
cout << "2\n";
cout << s[0] << " ";
s.erase(s.begin());
cout << s << endl;
}
//system("pause");
return 0;
}

浙公网安备 33010602011771号