正文
Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C. Plasticine zebra
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
问了学长,感觉还是很迷啊,不过懂了个大概,这个翻转操作,实质不就是在序列后面加上前面部分比如
bw | wwbwwbw 操作过后 wbwbwwbww
而 bw | wwbwwbwbw 这样我们就知道这样的实质了,因此我们只需要把序列再次倍增,求最长的间隔序列即可
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
int main(){
string a;
while(cin>>a){
int len1=a.length();
a=a+a;
int len=a.length();
int sum=;
int ans=;
for(int i=;i<len-;i++){
if (a[i]!=a[i+]){
sum++;
ans=max(ans,sum);
}else {
sum=;
}
}
ans=min(len1,ans);
cout<<ans<<endl;
}
return ;
}