Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- void solve(){
- ll n;
- cin>>n;
- string s;
- cin>>s;
- transform(s.begin(),s.end(),s.begin(),::tolower);
- ll i=0;
- while (i<s.length()-1){
- if (!(s[i]=='m' || s[i]=='e' || s[i]=='o' || s[i]=='w')){
- cout<<"NO\n";
- return;
- }
- if ((s[i]!=s[i+1]) && ((s[i]=='m' && s[i+1]!='e') || (s[i]=='e' && s[i+1]!='o') || (s[i]=='o' && s[i+1]!='w') || s[i]=='w')){
- cout<<"NO\n";
- return;
- }
- i++;
- }
- set <char> S;
- for (ll i=0; i<s.length(); i++){
- S.insert(s[i]);
- }
- if (S.size()==4) cout<<"YES\n";
- else cout<<"NO\n";
- }
- int main()
- {
- int t;
- cin>>t;
- while(t--){
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement