CF1025C.Plasticine zebra
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now wants to select several consequent (contiguous) pieces of alternating colors to create a zebra. Let's call the number of selected pieces the length of the zebra.
Before assembling the zebra Grisha can make the following operation 0 or more times. He splits the sequence in some place into two parts, then reverses each of them and sticks them together again. For example, if Grisha has pieces in the order "bwbbw" (here 'b' denotes a black strip, and 'w' denotes a white strip), then he can split the sequence as bw|bbw (here the vertical bar represents the cut), reverse both parts and obtain "wbwbb".
Determine the maximum possible length of the zebra that Grisha can produce.
在疲惫的工作周之后,还有什么比去动物园更令人愉悦的事情呢?怪不得格里沙整个周末都陪着漂亮的条纹斑马,也感到同样的兴奋。
受这次冒险以及偶然发现的一包橡皮泥(用一串黑白相间的条纹序列表示)的启发,格里沙现在希望从中选出若干连续的、颜色交替的片段来制作一条“斑马”。我们将所选片段的数量称为该“斑马”的长度。
在组装这条斑马之前,格里沙可以执行以下操作 0 次或多次:他在某个位置将序列切分为两部分,然后分别将这两部分反转,再将它们重新拼接在一起。例如,若格里沙当前的片段序列为 "bwbbw"(其中 'b' 表示黑色条纹,'w' 表示白色条纹),则他可以在 bw|bbw 处切割(此处竖线 | 表示切割位置),反转两部分后得到 "wbwbb"。
请确定格里沙所能构造出的斑马的最大可能长度。
输入格式
The only line contains a string s (1≤∣s∣≤105, where ∣s∣ denotes the length of the string s) comprised of lowercase English letters 'b' and 'w' only, where 'w' denotes a white piece and 'b' denotes a black piece.
唯一的一行包含一个字符串 s(1≤∣s∣≤105,其中 ∣s∣ 表示字符串 s 的长度),该字符串仅由小写英文字母 'b' 和 'w' 组成,其中 'w' 表示白色棋子,'b' 表示黑色棋子。
输出格式
Print a single integer — the maximum possible zebra length.
输出一个整数——最长可能的斑马序列长度。
输入输出样例
输入#1
bwwwbwwbw
输出#1
5
输入#2
bwwbwwb
输出#2
3
说明/提示
In the first example one of the possible sequence of operations is bwwwbww|bw → w|wbwwwbwb → wbwbwwwbw, that gives the answer equal to 5.
In the second example no operation can increase the answer.
在第一个例子中,一种可能的操作序列是 bwwwbww|bw → w|wbwwwbwb → wbwbwwwbw,得到的答案为 5。
在第二个例子中,没有任何操作能增大答案。
输入解题思路,AI测评打分。不知道怎么写?