-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
58 lines (55 loc) · 1.04 KB
/
C.cpp
File metadata and controls
58 lines (55 loc) · 1.04 KB
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
51
52
53
54
55
56
57
58
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,n,c;
string s;
cin>>t;
while(t--)
{
cin>>s;
c=1;
n=s.length();
vector <int> v;
bool b=true;
for(int i=0;i<n-1;i++)
{
if(s[i]=='L' && s[i+1]=='L')
{
c++;
b=false;
}
else if(s[i]=='L')
{
v.push_back(2);
//b=true;
}
else
{
c=1;
}
v.push_back(c);
//cout<<c<<' ';
}
if(n==1)
{
if(s=="R")
cout<<1<<endl;
else
{
cout<<2<<endl;
}
continue;
}
if(s[n-1]=='L')
v.push_back(2);
int m=*max_element(v.begin(),v.end());
if(m==1||b)
cout<<m<<endl;
else
{
cout<<m+1<<endl;
}
}
return 0;
}