#include #include #include #include #include #include using namespace std; vector names = {"digi", "petit", "rabi", "gema", "piyo"}; vector tails = {"nyo", "nyu", "", "gema", "pyo"}; bool check_tail(string &s, int idx) { int pos = s.rfind(tails[idx]); if (pos == string::npos) { return false; } string tail = s.substr(pos); if (tail.size() > tails[idx].size() + 3) { return false; } for (int k = tails[idx].size(); k < tail.size(); k++) { // if (isalnum(tail[k]) || tail[k] == ' ') { if (isalnum(tail[k])) { return false; } } return true; } bool check_rabi(string &s) { for (int j = 0; j < s.size(); j++) { if (isalnum(s[j])) { return true; } } return false; } int main() { string s; while (getline(cin, s)) { bool ok = false; for (int i = 0; i < names.size(); i++) { if (s.find(names[i] + " ") == 0) { s = s.substr(names[i].size() + 1); s = s.substr(max(0, (int) s.size() - 10)); transform(s.begin(), s.end(), s.begin(), ::tolower); if (names[i] == "rabi") { ok = check_rabi(s); } else { ok = check_tail(s, i); } } } cout << (ok ? "CORRECT (maybe)" : "WRONG!") << endl; } return 0; }