Codeforces round 855. A
原题链接
简单
作者:
好好好呵呵
,
2023-03-05 14:13:58
,
所有人可见
,
阅读 185
欢迎留言讨论
CF Round 855 A
code
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
string s;
bool check()
{
int n;
cin >> n;
cin >> s;
int cnt = 0;
bool a = true;
bool b = true;
bool c = true;
if(s[0]!='m' && s[0]!='M') return false;
for(int i = 0;i < n;i ++)
{
if(s[i]!='m'&& s[i]!='M'&& s[i] != 'e'&&s[i]!='E'&& s[i] != 'o'&&s[i]!='O'&& s[i] != 'w'&&s[i] != 'W')
return false;
if(cnt == 0)
{
if((s[i] == 'e' || s[i] == 'E') && a)
{
a = false;
cnt ++;
}
else if(s[i]!='m'&&s[i] != 'M') return false;
}
if(cnt == 1)
{
if((s[i] == 'o' || s[i] == 'O') && b)
{
b = false;
cnt ++;
}
else if(s[i]!='e'&&s[i] != 'E') return false;
}
if(cnt == 2)
{
if((s[i] == 'w' || s[i] == 'W') && c)
{
c = false;
cnt ++;
}
else if(s[i]!='o'&&s[i] != 'O') return false;
}
if(cnt == 3)
if(s[i]!='w'&&s[i] != 'W') return false;
}
if(cnt == 3) return true;
return false;
}
int main()
{
int t;
cin >> t;
while(t --)
{
if(check()) puts("YES");
else puts("NO");
}
}