Skip to content

Commit 8ede2ec

Browse files
committed
Added 1807C - Find and Replace.cpp
1 parent d42bf13 commit 8ede2ec

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

1807C - Find and Replace.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
5+
// Code Written By: Vikash Patel
6+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
7+
8+
bool visited(vector<pair<char,char>> ans , char ch)
9+
{
10+
for(auto i : ans)
11+
{
12+
if(i.first == ch)
13+
return true;
14+
}
15+
return false;
16+
}
17+
18+
bool checkPos(vector<pair<char,char>> ans , char ch, char c)
19+
{
20+
for(auto i : ans)
21+
{
22+
if(i.first==ch && i.second==c)
23+
return true;
24+
}
25+
return false;
26+
}
27+
28+
int main()
29+
{
30+
int t;
31+
cin>>t;
32+
while(t--)
33+
{
34+
int n;
35+
cin>>n;
36+
string s;
37+
cin>>s;
38+
vector<pair<char,char>> ans;
39+
bool sol = true;
40+
for(int i=0;i<n;i++)
41+
{
42+
char c;
43+
if(i%2==0)
44+
c = 'o';
45+
else
46+
c = 'e';
47+
if(!visited(ans,s[i]))
48+
{
49+
ans.push_back(make_pair(s[i],c));
50+
}
51+
if(checkPos(ans,s[i],c))
52+
{
53+
continue;
54+
}
55+
else
56+
{
57+
sol = false;
58+
break;
59+
}
60+
}
61+
if(sol)
62+
cout<<"YES"<<endl;
63+
else
64+
cout<<"NO"<<endl;
65+
}
66+
return 0;
67+
}

0 commit comments

Comments
 (0)