結果

問題 No.380 悪の台本
ユーザー dnishdnish
提出日時 2018-06-21 22:41:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 188 ms / 1,000 ms
コード長 1,720 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 180,560 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 07:41:48
合計ジャッジ時間 2,726 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll inf=1e18;


int main(){

    string s;
    map<string, string> m;
    m["digi"] = "nyo";
    m["petit"] = "nyu";
    m["gema"] = "gema";
    m["piyo"] = "pyo";
    string line, name;
    while (getline(cin, line)) {
        stringstream ss(line);
        ss >> name;
        if (line == name || !isalpha(line[0])) {
            cout << "WRONG!" << endl;
            continue;
        }
        line = line.substr(name.size() + 1);
        if (name == "rabi") {
            if (find_if(line.begin(), line.end(), [](char c){return isalnum(c);}) != line.end()) {
                cout << "CORRECT (maybe)" << endl;
            } else {
                cout << "WRONG!" << endl;
            }
        } else {
            if (!m.count(name)) {
                cout << "WRONG!" << endl;
                continue;
            }
            for (char& c : line) c = tolower(c);
            reverse(line.begin(), line.end());
            int cnt = find_if(line.begin(), line.end(), [](char c){return isalnum(c);}) - line.begin();
            reverse(line.begin(), line.end());
            if (cnt <= 3 && cnt + m[name].size() <= line.size() && m[name] == line.substr(line.size() - cnt - m[name].size(), m[name].size())) {
                cout << "CORRECT (maybe)" << endl;
            } else {
                cout << "WRONG!" << endl;
            }
        }
    }

    return 0;
}
0