- Quiz
- AC
- 解説
- 画像のように、どこで切っても文字列は循環している
- 文字列を2倍の長さにして探索すればいい
- 視点
- 「操作をしても変わらない性質」はないだろうか?
int main(){ cin.tie(0); ios::sync_with_stdio(false); // input string s;cin>>s; ll N = s.size(); string t = s+s; ll ma=1; ll len=1; char now=t[0]; FOR(i,1,2*N){ char c = t[i]; if(now!=c){ len++; }else{ len=1; } now=c; chmax(ma,len); } ll ans = min(N,ma); p(ans); return 0; }