結果

問題 No.380 悪の台本
ユーザー h_nosonh_noson
提出日時 2016-06-18 00:29:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 127 ms / 1,000 ms
コード長 1,708 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 69,848 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:27:57
合計ジャッジ時間 1,234 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
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 14 ms
5,376 KB
testcase_07 AC 127 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+7)

typedef long long ll;

bool is_symbol(char c) {
    if ('a' <= c && c <= 'z') return false;
    if ('A' <= c && c <= 'Z') return false;
    if ('0' <= c && c <= '9') return false;
    return true;
}

bool include(string s, string t) {
    int i, j;
    rep (i,min((int)s.size()-(int)t.size()+1,4)) {
        string sub = s.substr(s.size()-i-t.size(),t.size());
        bool ok = true;
        REP (j,s.size()-i,s.size()-1) ok &= is_symbol(s[j]);
        if (!ok) continue;
        transform(sub.begin(),sub.end(),sub.begin(),[](char c) {return tolower(c);});
        if (sub == t)
            return true;
    }
    return false;
}

int main(void) {
    int i;
    string s;
    while (getline(cin,s)) {
        string name;
        for (auto c : s) {
            if (c == ' ')
                break;
            name += c;
        }
        s = s.substr(min(s.size(),name.size()+1));
        bool ok = false;
        if (name == "digi")
            ok = include(s,"nyo");
        else if (name == "petit")
            ok = include(s,"nyu");
        else if (name == "rabi")
            for (auto c : s) ok |= !is_symbol(c);
        else if (name == "gema")
            ok = include(s,"gema");
        else if (name == "piyo")
            ok = include(s,"pyo");
        if (ok)
            cout << "CORRECT (maybe)" << endl;
        else
            cout << "WRONG!" << endl;
    }
    return 0;
}
0