結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-17 22:46:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,719 bytes |
| コンパイル時間 | 1,396 ms |
| コンパイル使用メモリ | 162,268 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 22:36:40 |
| 合計ジャッジ時間 | 2,319 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 1 WA * 4 RE * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
string to_lower(string s) {
for (char &c : s) if (isalpha(c)) c = tolower(c);
return s;
}
pair<string, string> split(string s) {
int i = 0;
while (i < s.size() && s[i] != ' ') i++;
return make_pair(s.substr(0, i), s.substr(i + 1));
}
bool is_digi(string s) {
if (s == "nyo") return true;
for (int i = 0; i < 3; i++) {
if (s.size() <= 2) return false;
if (s.substr(s.size() - 3) == "nyo") return true;
s.pop_back();
}
return false;
}
bool is_petit(string s) {
if (s == "nyu") return true;
for (int i = 0; i < 3; i++) {
if (s.size() <= 2) return false;
if (s.substr(s.size() - 3) == "nyu") return true;
s.pop_back();
}
return false;
}
bool is_rabi(string s) {
for (char c : s) {
if (isdigit(c) || isalpha(c)) return true;
}
return false;
}
bool is_gema(string s) {
if (s == "gema") return true;
for (int i = 0; i < 3; i++) {
if (s.size() <= 3) return false;
if (s.substr(s.size() - 4) == "gema") return true;
s.pop_back();
}
return false;
}
bool is_piyo(string s) {
if (s == "pyo") return true;
for (int i = 0; i < 3; i++) {
if (s.size() <= 2) return false;
if (s.substr(s.size() - 3) == "pyo") return true;
s.pop_back();
}
return false;
}
bool solve(string s) {
auto v = split(s);
string t = to_lower(v.second);
if (v.first == "digi") {
return is_digi(t);
} else if (v.first == "petit") {
return is_petit(t);
} else if (v.first == "rabi") {
return is_rabi(t);
} else if (v.first == "gema") {
return is_gema(t);
} else if (v.first == "piyo") {
return is_piyo(s);
} else {
return false;
}
}
int main() {
string s;
while (getline(cin, s)) {
puts(solve(s) ? "CORRECT(maybe)" : "WRONG!");
}
}