結果

問題 No.380 悪の台本
ユーザー tubo28
提出日時 2016-06-17 23:35:53
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 2,322 bytes
コンパイル時間 961 ms
コンパイル使用メモリ 105,872 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-06 22:43:05
合計ジャッジ時間 1,688 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using ll = long long;
#define all(v) begin(v), end(v)
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
bool ispunc(char c) {
return !(isdigit(c) | isalpha(c));
}
bool typical(string &say, string tail) {
string punc;
while (say.size() && ispunc(say.back())){
punc += say.back();
say.pop_back();
}
if (punc.size() > 3) {
return false;
}
if (say.size() < tail.size()) return false;
return tail == say.substr(say.size() - tail.size(), tail.size());
}
bool rabi(string &say) {
return any_of(all(say), [](char c) { return !ispunc(c); });
}
bool checkbody(string &name, string &body) {
for (auto &c : body) c = tolower(c);
if (body.size() == 0 && body[0] != ' ') return false;
if (name == "digi" && typical(body, "nyo")) return true;
if (name == "petit" && typical(body, "nyu")) return true;
if (name == "rabi" && rabi(body)) return true;
if (name == "gema" && typical(body, "gema")) return true;
if (name == "piyo" && typical(body, "pyo")) return true;
return false;
}
bool checkname(string &name) {
static const vector<string> oknames = { "digi","petit","rabi","gema","piyo" };
return find(all(oknames), name) != oknames.end();
}
bool check(string &line) {
string name;
int k = 0;
while (k < line.size() && !ispunc(line[k])) {
name += line[k];
++k;
}
if (k == line.size() || line[k] != ' ') return false;
++k;
string body = line.substr(k);
return checkbody(name, body);
}
int main() {
string line;
while (getline(cin, line)) {
puts(check(line) ? "CORRECT (maybe)" : "WRONG!");
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0