Advertisement
fooker

P1800A

Mar 2nd, 2023
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. void solve(){
  5.     ll n;
  6.     cin>>n;
  7.     string s;
  8.     cin>>s;
  9.     transform(s.begin(),s.end(),s.begin(),::tolower);
  10.     ll i=0;
  11.     while (i<s.length()-1){
  12.         if (!(s[i]=='m' || s[i]=='e' || s[i]=='o' || s[i]=='w')){
  13.             cout<<"NO\n";
  14.             return;
  15.         }
  16.         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')){
  17.             cout<<"NO\n";
  18.             return;
  19.         }
  20.         i++;
  21.     }
  22.     set <char> S;
  23.     for (ll i=0; i<s.length(); i++){
  24.         S.insert(s[i]);
  25.     }
  26.     if (S.size()==4) cout<<"YES\n";
  27.     else cout<<"NO\n";
  28.  
  29. }
  30. int main()
  31. {
  32.     int t;
  33.     cin>>t;
  34.     while(t--){
  35.         solve();
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement