题意:定义一个字符串是good,如果满足
1:长度是偶数
2:对每个奇数位置满足s[i] != s[i+1](1-base)
问最少删除几个字符可以使原字符串是good
贪心
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
string res;
int main()
{
cin >> n >> s;
for(int i = 0; i < n; i++)
{
if(res.size() % 2 == 0 || res.back() != s[i])
res.push_back(s[i]);
}
if(res.size() % 2 == 1)
res.pop_back();
cout << n - int(res.size()) << endl << res << endl;
return 0;
}