-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1644_A_Doors_and_Keys.cpp
47 lines (44 loc) · 1.07 KB
/
1644_A_Doors_and_Keys.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
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
string str;
cin >> str;
int r = 0, b = 0, g = 0;
bool flag = true;
for(int i=0; i<str.size(); i++){
if(str[i] == 'r'){
r++;
}else if(str[i] == 'b'){
b++;
}else if(str[i] == 'g'){
g++;
}
else if(str[i] == 'R'){
if(r == 0) {
cout << "NO" << endl;
flag = false;
break;
}
}
else if(str[i] == 'B'){
if(b == 0) {
cout << "NO" << endl;
flag = false;
break;
}
}
else if(str[i] == 'G'){
if(g == 0) {
cout << "NO" << endl;
flag = false;
break;
}
}
}
if(flag) cout << "YES" << endl;
}
return 0;
}