ACM:M: 1 VS 1

来源:互联网 发布:外汇指标软件视频 编辑:程序博客网 时间:2024/05/21 07:03

ACM:M: 1 VS 1

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
感觉题目就是到处扯,其实就还是看最长的字符串长度。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <ctime>
#define LL long long
#define MAX(a,b)((a)>(b)?a:b)
#define MIN(a,b)((a)<(b)?a:b)
#define INF 0x7ffffff
#define N 1005
#define M 15
using namespace std;
//char str[N];
int main()
{
    string str;
    while(cin>>str)
    {
        int max=0;
        int con=1;
        for(int i=0;i<str.length();i++)
        {
            if(str[i]==str[i+1])
            {
                con++;
                if(con>max)
                    max=con;
            }
            else
                con=1;
        }
        cout<<max<<endl;
    }
    return 0;
}
原创粉丝点击