codeforces cf round#505(based on vk cup 2018 final) C. Plasticine zebra
Posted lishengkangshidatiancai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces cf round#505(based on vk cup 2018 final) C. Plasticine zebra相关的知识,希望对你有一定的参考价值。
构造题,把整个串想象成一个环。每次把环断开并反转的时候从切口处看进去的顺序是和刚开始从头到尾的顺序是一样的。于是每次不管如何翻转最后都要找到这个环上最大的连续子段长度
#include<bits/stdc++.h> using namespace std; string s; int main() { cin>>s; int tmp=s.size(); s=s+s; int ans=0; int len=1; for(int i=0;i<(int)s.size()-1;i++) { if(s[i]==‘b‘&&s[i+1]==‘w‘||s[i]==‘w‘&&s[i+1]==‘b‘) { len++; } else { ans=max(ans,len); len=1; } } ans=max(len,ans); printf("%d ",min(ans,tmp)); }
以上是关于codeforces cf round#505(based on vk cup 2018 final) C. Plasticine zebra的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) -B C(GCD,最长连续交替序列)
Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) 题解
CF #1354 Educational Codeforces Round 87
Codeforces Round #505 (Div 1 + Div 2 Combined) Partial Solution