-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1671A - String Building.cpp
55 lines (51 loc) · 1.02 KB
/
1671A - String Building.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
51
52
53
54
55
// ॐ नमः शिवाय
#include<bits/stdc++.h>
using namespace std;
#define ll long long
// Code Written By: Vikash Patel
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
bool solve(string s)
{
int j = 0;
int i;
for(i=0; i<s.size(); i++)
{
string s1 = s.substr(j+i, 2);
string s2 = s.substr(j+i, 3);
if(s2 == "aaa" || s2 == "bbb")
i += 3;
else if(s1 == "aa" || s1 == "bb")
i += 2;
j = i;
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
string s;
cin>>s;
bool ans = 1;
for(int i=0; i<s.size(); i++)
{
int c = 1;
while(s[i]==s[i+1] && i+1<s.size())
{
c++;
i++;
}
if(c<2)
{
ans = 0;
break;
}
}
if(ans)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}