結果

問題 No.380 悪の台本
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-26 19:25:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 1,000 ms
コード長 1,588 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 206,708 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 12:45:24
合計ジャッジ時間 2,997 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool issign(char c) {
    return !isalpha(c)&&!isdigit(c);
}

string tolowers(string s) {
    for (char& c:s)
        c=tolower(c);
    return s;
}

int main() {
    string s;
    map<string,string> guys={{"digi","nyo"},{"petit","nyu"},{"rabi",""},{"gema","gema"},{"piyo","pyo"}};
    while (getline(cin,s)) {
        int n=s.size();
        int i=0;
        string name;
        while (i<n&&s[i]!=' ') {
            name+=s[i];
            i++;
        }
        if (guys.find(name)==guys.end()) {
            puts("WRONG!");
            continue;
        }
        i++;
        if (n<=i) {
            puts("WRONG!");
            continue;
        }
        s=s.substr(i);
        if (name=="rabi") {
            bool f=0;
            for (char c:s) {
                if (isalpha(c)||isdigit(c)) {
                    f=1;
                    break;
                }
            }
            if (f) puts("CORRECT (maybe)");
            else puts("WRONG!");
            continue;
        }
        int r=s.size();
        r--;
        int cnt=0;
        while (0<=r&&issign(s[r])) {
            cnt++;
            r--;
        }
        if (cnt>3) {
            puts("WRONG!");
            continue;
        }
        string suf=guys[name];
        int l=r-suf.size()+1;
        if (l<0) {
            puts("WRONG!");
            continue;
        }
        if (tolowers(s.substr(l,suf.size()))==suf) {
            puts("CORRECT (maybe)");
        } else {
            puts("WRONG!");
        }
    }
    return 0;
}
0