/* -*- coding: utf-8 -*- * * 380.cc: No.380 悪の台本 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ /* typedef */ typedef vector vs; /* global variables */ /* subroutines */ string readword(string &s, int &pos) { while (pos < s.size() && s[pos] == ' ') pos++; string w; while (pos < s.size() && s[pos] != ' ') w += s[pos++]; return w; } inline bool is_upper(char c) { return (c >= 'A' && c <= 'Z'); } inline bool is_lower(char c) { return (c >= 'a' && c <= 'z'); } inline bool is_digit(char c) { return (c >= '0' && c <= '9'); } inline bool not_symbol(char c) { return is_upper(c) || is_lower(c) || is_digit(c); } inline bool is_symbol(char c) { return ! not_symbol(c); } bool end_with(string &w, string key) { int wn = w.size(), kn = key.size(); int l = wn; while (l > 0 && is_symbol(w[l - 1])) l--; if (wn - l > 3 || l < kn) return false; for (int i = 0; i < kn; i++) { char c = w[l - kn + i]; if (is_upper(c)) c += 'a' - 'A'; if (c != key[i]) return false; } return true; } /* main */ int main() { for (;;) { string s; getline(cin, s); if (cin.eof()) break; vs v; for (int pos = 0;;) { string w = readword(s, pos); if (w.empty()) break; v.push_back(w); } int n = v.size(); //printf("%d\n", n); if (n <= 1) { puts("WRONG!"); continue; } bool ok = false; string &name = v.front(), &lw = v.back(); if (name == "digi") ok = end_with(lw, "nyo"); else if (name == "petit") ok = end_with(lw, "nyu"); else if (name == "gema") ok = end_with(lw, "gema"); else if (name == "piyo") ok = end_with(lw, "pyo"); else if (name == "rabi") { for (int i = 1; ! ok && i < n; i++) for (int j = 0; ! ok && j < v[i].size(); j++) ok = not_symbol(v[i][j]); } cout << (ok ? "CORRECT (maybe)" : "WRONG!") << endl; } return 0; }