-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1671A.cpp
43 lines (41 loc) · 860 Bytes
/
1671A.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
#include <iostream>
#include <string>
int main()
{
int t;
std::cin>>t;
for(int j = 0; j < t; j++){
std::string str;
std::cin>>str;
int count_a = 0;
int count_b = 0;
bool f = true;
//std::cout << str.size();
for(int i = 0; i < str.size() && f; i++){
if (str[i] == 'a'){
if (count_b == 1){
f = false;
}
else{
count_b = 0;
}
count_a += 1;
}
else{
if (count_a == 1){
f = false;
}
else{
count_a = 0;
}
count_b += 1;
}
}
if (f && (count_a + count_b) != 1){
std::cout<<"YES"<<std::endl;
}
else{
std::cout<<"NO"<<std::endl;
}
}
}