题意:给你一个01串,必须替换一次,且替换的为子串。问换完后,最大01串长度。
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
int n,sum = ;
string s;
cin >> n >> s;
char last = s[];
for(int i = ; i < n ; i ++)
{
if(last != s[i])
{
sum ++;
last = s[i];
}
}
if(sum >= n - )
cout << n << endl;
else
cout << sum + << endl;
return ;
}