当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2638:Greed is good

题目描述
As we all know Uncle CTW is a very greedy uncle,he likes collecting jewels.One day he gets a necklace with beautiful gems,he has a strange habit,that he only collects the contiguous gems with with same color.That means if he pick a red gem at first,and he will continue to pick only if the next gem is red,or he will stop.(That's why people call him "Uncle.Strange").
As it is a necklace,he must find somewhere to cut the necklace at the very begining,then select an end to pick until meet a different color gem,and do the same for the other end (which might not be of the same color as the gems collected before this).
There are only three kinds of gems,red('r'),pink('p'),and white('w'),and NOTICE that,because the white one could be painted,so it can be seen as either color.(See the sample for detail.)
Now he just want to know the maximum number of gems he can collect,could you tell him?
输入解释
The first line contain an integer T,then T lines,each line with a string only contain r,p or w ,with length no more than 400.
输出解释
One integer per line indicating the maximum nunber.
输入样例
1
wwwpprwrprprrprprwrwwrpwrwrrp
输出样例
11


Hint:
Consider two copies of the beads (kind of like being able to runaround the ends). The string of 11 is marked. 
wwwpprwrprprrprprwrwwrpwrwrrp wwwpprwrprprrprprwrwwrpwrwrrp
                       ****** *****
来自杭电HDUOJ的附加信息
Author teddy
Recommend teddy

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 百万秦关终属楚

源链接: HDU-2638

最后修改于 2020-10-25T22:55:27+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)