-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLT23.cpp
More file actions
56 lines (53 loc) · 752 Bytes
/
LT23.cpp
File metadata and controls
56 lines (53 loc) · 752 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
long len;
char L1,L2,V[1000001];
scanf("%d",&t);
while(t--){
bool flag = 0;
fill(V,V+1000001,0);
scanf("%s",V);
L1 = V[0]; L2=V[1]; len = strlen(V);
if(L2==L1){
flag = 1;
goto ans;
}
for(long i=0;i<len;){
if(i!=len-1){
if(L1==V[i] && L2==V[i+1]){
i+=2;
}
else{
flag = 1;
break;
}
}
else{
if(i%2==0){
if(L1!=V[i])
{
flag = 1;
break;
}
else{
i++;
}
}
else{
if(L2!=V[i]){
flag = 1;
break;
}
else{
i++;
}
}
}
}
ans : (flag)?printf("NO\n"):printf("YES\n");
}
return 0;
}