結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-17 23:49:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,301 bytes |
| コンパイル時間 | 676 ms |
| コンパイル使用メモリ | 66,308 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 22:45:43 |
| 合計ジャッジ時間 | 1,495 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 7 WA * 1 |
ソースコード
#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() > tails[idx].size() + 3) {
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])) {
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);
int pos = 0;
while (s[pos] == ' ') {
pos++;
}
s = s.substr(pos);
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;
}