結果

問題 No.380 悪の台本
ユーザー tottoripapertottoripaper
提出日時 2018-03-11 16:40:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,914 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 167,812 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 01:06:33
合計ジャッジ時間 3,283 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

string line;

bool isSymbol(char c){
    return !isalnum(c);
}

bool isDialogueWith(string str, string suffix){
    int s = str.size() - 1;
    while(s >= 0 && isSymbol(str[s])){
        --s;
    }

    int s_cnt = str.size() - 1 - s;
    if(s_cnt > 3){
        return false;
    }

    string tail = str.substr(s - suffix.size() + 1, suffix.size());
    return tail == suffix;
}

bool isValid(){
    if(line.size() < 5){
        return false;
    }

    if(line.substr(0, 5) == "digi "){
        return isDialogueWith(line.substr(5), "nyo");
    }else if(line.substr(0, 5) == "rabi "){
        string tail = line.substr(5);
        return any_of(tail.begin(), tail.end(), [](char c){
                return isalnum(c);
            });
    }else if(line.substr(0, 5) == "gema "){
        return isDialogueWith(line.substr(5), "gema");
    }else if(line.substr(0, 5) == "piyo "){
        return isDialogueWith(line.substr(5), "pyo");
    }else if(line.size() >= 6 && line.substr(0, 6) == "petit "){
        return isDialogueWith(line.substr(6), "nyu");        
    }

    return false;
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    while(true){        
        getline(cin, line);
        
        if(cin.eof()){
            break;
        }
        
        transform(line.begin(), line.end(), line.begin(), [](char c){
                return tolower(c);
            });
        
        if(isValid()){
            std::cout << "CORRECT (maybe)" << std::endl;
        }else{
            std::cout << "WRONG!" << std::endl;
        }
    }
}
0