結果

問題 No.380 悪の台本
ユーザー tubo28tubo28
提出日時 2016-06-17 23:28:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,300 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 105,908 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:19:50
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 15 ms
5,376 KB
testcase_06 AC 15 ms
5,376 KB
testcase_07 AC 123 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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 typical(string &say, string tail) {
    string punc;
    while (say.size() &&
        !isalpha(say.back()) &&
        !isdigit(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 isalpha(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() && isalpha(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!");
    }
}
0