Skip to content

Commit 2271005

Browse files
committed
Added 1671A - String Building.cpp
1 parent daeb81f commit 2271005

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

1671A - String Building.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
}

0 commit comments

Comments
 (0)