結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-17 23:25:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,211 bytes |
| コンパイル時間 | 705 ms |
| コンパイル使用メモリ | 66,412 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 22:41:25 |
| 合計ジャッジ時間 | 1,564 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 WA * 5 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
vector<string> names = {"digi", "petit", "rabi", "gema", "piyo"};
vector<string> 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() > 6) {
return false;
}
for (int k = tails[idx].size(); k < tail.size(); 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]) && 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;
}