結果

問題 No.380 悪の台本
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-07-05 18:10:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,025 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 173,404 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:38:58
合計ジャッジ時間 2,208 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 + last.size() > 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 (not cin.eof()) {
            getline(cin, s);
            if (s[0] == ' ') {
                cout << "WRONG!" << endl;
                continue;
            }
            istringstream is(s);
            string c; is >> c;
            string t = s.substr(c.size(), s.size() - c.size());
            for (auto& x : t) x = tolower(x);
            cout << (check(c, t) ? "CORRECT (maybe)" : "WRONG!") << endl;
        }
    }
}

int main() {
    solve();
    return 0;
}

0