-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1800A - Is It a Cat.cpp
63 lines (58 loc) · 993 Bytes
/
1800A - Is It a Cat.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
#include<bits/stdc++.h>
using namespace std;
// Code Written By: Vikash Patel
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
bool checkMeow( string s, int n)
{
transform(s.begin(),s.end(),s.begin(), ::tolower);
int m,e,o,w;
m=e=o=w=0;
for(int i=0;i<n;i++)
{
if(s[i]=='m')
m++;
else
break;
}
for(int i=m;i<n;i++)
{
if(s[i]=='e')
e++;
else
break;
}
for(int i=m+e;i<n;i++)
{
if(s[i]=='o')
o++;
else
break;
}
for(int i=m+e+o;i<n;i++)
{
if(s[i]=='w')
w++;
else
break;
}
if(m+e+o+w==n && m>0 && e>0 && o>0 && w>0)
return true;
else
return false;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
if(checkMeow(s,n))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}