File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ // ॐ नमः शिवाय
2
+ #include < bits/stdc++.h>
3
+ using namespace std ;
4
+ #define ll long long
5
+
6
+ // Code Written By: Vikash Patel
7
+ // Codeforces Profile: https://codeforces.com/profile/vikashpatel
8
+
9
+
10
+ bool solve (string s)
11
+ {
12
+ int j = 0 ;
13
+ int i;
14
+ for (i=0 ; i<s.size (); i++)
15
+ {
16
+ string s1 = s.substr (j+i, 2 );
17
+ string s2 = s.substr (j+i, 3 );
18
+ if (s2 == " aaa" || s2 == " bbb" )
19
+ i += 3 ;
20
+ else if (s1 == " aa" || s1 == " bb" )
21
+ i += 2 ;
22
+ j = i;
23
+ }
24
+ }
25
+
26
+ int main ()
27
+ {
28
+ int t;
29
+ cin>>t;
30
+ while (t--)
31
+ {
32
+ string s;
33
+ cin>>s;
34
+ bool ans = 1 ;
35
+ for (int i=0 ; i<s.size (); i++)
36
+ {
37
+ int c = 1 ;
38
+ while (s[i]==s[i+1 ] && i+1 <s.size ())
39
+ {
40
+ c++;
41
+ i++;
42
+ }
43
+ if (c<2 )
44
+ {
45
+ ans = 0 ;
46
+ break ;
47
+ }
48
+ }
49
+ if (ans)
50
+ cout<<" YES" <<endl;
51
+ else
52
+ cout<<" NO" <<endl;
53
+ }
54
+ return 0 ;
55
+ }
You can’t perform that action at this time.
0 commit comments