結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-07-05 17:38:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,883 bytes |
| コンパイル時間 | 1,591 ms |
| コンパイル使用メモリ | 173,404 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 23:03:47 |
| 合計ジャッジ時間 | 2,905 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 RE * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef double real;
typedef long long ll;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
os << "[" << vs[0];
for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
return os << "]";
}
template<class T> istream& operator>>(istream& is, vector<T>& vs) {
for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
return is;
}
bool check_rabi(string t) {
for (int i = 0; i < t.size(); i++) {
if (isdigit(t[i]) || isalpha(t[i])) {
return true;
}
}
return false;
}
map<string, string> M;
void init() {
M["digi"] = "nyo";
M["petit"] = "nyu";
M["gema"] = "gema";
M["piyo"] = "pyo";
}
bool check(string c, string t) {
if (c == "rabi") return check_rabi(t);
if (M.count(c) == 0) return false;
string last = M[c];
int count = 0;
for (int i = t.size() - 1; i >= 0; i--) {
if (not (isdigit(t[i]) || isalpha(t[i]))) {
count++;
} else {
break;
}
}
if (count > 3) return false;
if (count + 3 > t.size()) return false;
t = t.substr(0, t.size() - count);
return t.substr(t.size() - last.size(), last.size()) == last;
}
void solve() {
init();
string s;
while (getline(cin, s)) {
istringstream is(s);
string c; is >> c;
string t = s.substr(c.size() + 1, s.size() - c.size() - 1);
for (auto& x : t) x = tolower(x);
cout << (check(c, t) ? "CORRECT (maybe)" : "WRONG!") << endl;
}
}
}
int main() {
solve();
return 0;
}
izuru_matsuura