模拟
2024-09-25 22:47:59
发布于:云南
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
bool cat(string s,int l){
for(int i = 0;i < l;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;
}
string key = "meow";
string key2 = "MEOW";
char lastkey = 'm';
int idx = 0;
for(int i = 0;i < l;i++){
if(idx == 3) return true;
if(s[i] == key[idx] || s[i] == key2[idx]){
idx++;
if(s[i] >= 'a' && s[i] <= 'z') lastkey = s[i];
else lastkey = (char)(s[i] + 32);
}else if(!(s[i] == lastkey || s[i] + 32 == lastkey)) return false;
}
return false;
}
int main(){
int T; cin >> T;
while(T--){
int size; cin >> size;
string s; cin >> s;
if(cat(s,size)) cout << "YES";
else cout << "NO";
cout << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个