标签:翻转 min else clu nbsp style ret include ++
/* bwwwbwwbw wwbwwwbwb 不管从哪里断开翻转。翻转后的串再整体翻转一定是2s的子串 */ #include<bits/stdc++.h> using namespace std; int len; char s[1000000]; int main(){ cin>>s+1; int len=strlen(s+1); if(len==1){ puts("1"); return 0; } for(int i=len+1;i<=len*2;i++) s[i]=s[i-len]; int ans=0,l=0; for(int i=1;i<=len*2;i++){ if(s[i]!=s[i-1]) l++; else ans=max(ans,l),l=1; // cout<<l<<‘\n‘; } if(ans==0)ans=l; printf("%d\n",min(ans,len)); }
标签:翻转 min else clu nbsp style ret include ++
原文地址:https://www.cnblogs.com/zsben991126/p/10372427.html