-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path1 VS 1.cpp
50 lines (46 loc) · 1.32 KB
/
1 VS 1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
using namespace std;
int main()
{
char a[1000];
while(cin >> a)
{
int i,k=strlen(a),sum=0,max=0,flag=1;
char lab=a[0];
for(i=0;i<k;i++)
{
if(a[i]==lab)
sum++;
else {
lab=a[i];
if(sum>max)
max=sum;
sum=1;
flag=0;
}
}
if(sum>max)
max=sum;
if(flag)
cout << sum << '\n';
else
cout << max << '\n';
}
return 0;
}
/*
Problem 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 uppercase '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
AAABBAAAAA
AABBBBAA
AAAAAAAA
Sample Output
5
4
8
*/