結果

問題 No.380 悪の台本
ユーザー tubo28tubo28
提出日時 2016-06-17 23:35:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 125 ms / 1,000 ms
コード長 2,322 bytes
コンパイル時間 919 ms
コンパイル使用メモリ 104,700 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-06 19:40:24
合計ジャッジ時間 1,766 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 6 ms
4,384 KB
testcase_05 AC 16 ms
4,384 KB
testcase_06 AC 16 ms
4,380 KB
testcase_07 AC 125 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 7 ms
4,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 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!");
    }
}
0