結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-07-13 20:34:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,232 bytes |
| コンパイル時間 | 816 ms |
| コンパイル使用メモリ | 90,404 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 23:07:32 |
| 合計ジャッジ時間 | 1,667 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 WA * 5 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 380.cc: No.380 悪の台本 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
/* typedef */
typedef vector<string> vs;
/* global variables */
/* subroutines */
string readword(string &s, int &pos) {
while (pos < s.size() && s[pos] == ' ') pos++;
string w;
while (pos < s.size() && s[pos] != ' ') w += s[pos++];
return w;
}
inline bool is_upper(char c) { return (c >= 'A' && c <= 'Z'); }
inline bool is_lower(char c) { return (c >= 'a' && c <= 'z'); }
inline bool is_digit(char c) { return (c >= '0' && c <= '9'); }
inline bool not_symbol(char c) {
return is_upper(c) || is_lower(c) || is_digit(c);
}
inline bool is_symbol(char c) { return ! not_symbol(c); }
bool end_with(string &w, string key) {
int wn = w.size(), kn = key.size();
int l = wn;
while (l > 0 && is_symbol(w[l - 1])) l--;
if (wn - l > 3 || l < kn) return false;
for (int i = 0; i < kn; i++) {
char c = w[l - kn + i];
if (is_upper(c)) c += 'a' - 'A';
if (c != key[i]) return false;
}
return true;
}
/* main */
int main() {
for (;;) {
string s;
getline(cin, s);
if (cin.eof()) break;
vs v;
for (int pos = 0;;) {
string w = readword(s, pos);
if (w.empty()) break;
v.push_back(w);
}
int n = v.size();
//printf("%d\n", n);
if (n <= 1) {
puts("WRONG!");
continue;
}
bool ok = false;
string &name = v.front(), &lw = v.back();
if (name == "digi")
ok = end_with(lw, "nyo");
else if (name == "petit")
ok = end_with(lw, "nyu");
else if (name == "gema")
ok = end_with(lw, "gema");
else if (name == "piyo")
ok = end_with(lw, "pyo");
else if (name == "rabi") {
for (int i = 1; ! ok && i < n; i++)
for (int j = 0; ! ok && j < v[i].size(); j++)
ok = not_symbol(v[i][j]);
}
cout << (ok ? "CORRECT (maybe)" : "WRONG!") << endl;
}
return 0;
}
tnakao0123