-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1807C - Find and Replace.cpp
67 lines (63 loc) · 1.27 KB
/
1807C - Find and Replace.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
56
57
58
59
60
61
62
63
64
65
66
67
// ॐ नमः शिवाय
#include<bits/stdc++.h>
using namespace std;
// Code Written By: Vikash Patel
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
bool visited(vector<pair<char,char>> ans , char ch)
{
for(auto i : ans)
{
if(i.first == ch)
return true;
}
return false;
}
bool checkPos(vector<pair<char,char>> ans , char ch, char c)
{
for(auto i : ans)
{
if(i.first==ch && i.second==c)
return true;
}
return false;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
vector<pair<char,char>> ans;
bool sol = true;
for(int i=0;i<n;i++)
{
char c;
if(i%2==0)
c = 'o';
else
c = 'e';
if(!visited(ans,s[i]))
{
ans.push_back(make_pair(s[i],c));
}
if(checkPos(ans,s[i],c))
{
continue;
}
else
{
sol = false;
break;
}
}
if(sol)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}