-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBEAUTGARjms.cpp
More file actions
53 lines (49 loc) · 1.17 KB
/
BEAUTGARjms.cpp
File metadata and controls
53 lines (49 loc) · 1.17 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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
string str;
cin>>str;
char start=str[0];
char last=str[str.length()-1];
int countr=0,countg=0,count1=0;
for(int i=0;i<str.length()-1;i++)
{
if(str[i]==str[i+1]&&str[i]=='R')
{count1++;
countr++;
}
if(str[i]==str[i+1]&&str[i]=='G')
{count1++;
countg++;
}
}
if(last==start&& last=='R')
{
count1++;
countr++;
}
if(last==start&& last=='G')
{
count1++;
countg++;
}
if(count1==2||count1==0)
{
if(count1==0)
cout<<"yes\n";
else{
if(countg!=countr)
cout<<"no\n";
else
cout<<"yes\n";
}
}
else
cout<<"no\n";
}
}