1 VS 1

来源:互联网 发布:jmeter 引用java文件 编辑:程序博客网 时间:2024/05/17 01:50


Description

      Alice and Bob are playing the game SanguoSha 1VS1.If Alice take a card or use a card (it may be slash,missed,peach,duel,sabotage or theft and so on) or discard (sometimes he does not need to throw any card) we will write down an uppercase 'A', if Bob does this, of course, we will write down the letter 'B'. Tell me the length of the longest operation combo performed by either player.

Input


      There are several test cases, each test case contains only a string composed of uppercaser 'A' and 'B'.The input will finish with the end of file.The length of the string is no more than 1000.

Output


     For each the case, output an integer indicate for the length.

Sample Input

AAABBAAAAAAABBBBAAAAAAAAAA

Sample Output

548

HINT

#include<iostream>
#include<cstring>
using namespace std;
main()
{
 char a[1001];
 while(scanf("%s",a)!=EOF){
  string s=a;
  int max=0,t=0;
  for(int i=0;i<s.length();i++){
   if(s[i]==s[i+1]) {t++; if(t>max) max=t;}
   else t=0;
  }
  printf("%d\n",max+1);
 }
}

我都佩服自己的智慧    2333333333

0 0