fork download
  1. #include <regex>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main() {
  6. regex re("nya+n");
  7. string s;
  8. while (cin >> s) {
  9. bool res = regex_match(s, re);
  10. cout << (res?"YES":"NO") << endl;
  11. }
  12. return 0;
  13. }
Success #stdin #stdout 0s 4176KB
stdin
nyan
nyaan
nyaaaaaan
nyn
nyaa
stdout
YES
YES
YES
NO
NO