結果

問題 No.380 悪の台本
ユーザー ngtkanangtkana
提出日時 2020-04-05 19:29:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 1,000 ms
コード長 1,728 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 212,424 KB
実行使用メモリ 8,540 KB
最終ジャッジ日時 2023-09-17 00:32:31
合計ジャッジ時間 2,671 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
bool issymbol(char c){return !std::isalnum(c);}
#define ERR {\
    std::cout<<"WRONG!"<<'\n';\
    continue;\
}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::map<std::string,std::string>map={
        {"digi","nyo"},
        {"petit","nyu"},
        {"gema","gema"},
        {"piyo","pyo"}
    };
    std::vector<std::string>lines;
    while(true){
        std::string s;std::getline(std::cin,s);
        if(std::cin.eof())break;
        lines.push_back(s);
    }
    for(lint line=0;line<(lint)lines.size();line++){
        std::string s=lines.at(line);
        lint n=s.length();
        lint l=0;
        for(;l<n&&s.at(l)!=' ';l++);
        if(l==n)ERR;
        std::string name=s.substr(0,l);
        l++;
        if(name=="rabi"){
            bool found=false;
            for(char c:s.substr(l,n-l)){
                if(issymbol(c))continue;
                found=true;
                break;
            }
            if(!found)ERR
        }else {
            auto it=map.find(name);
            if(it==map.end())ERR;
            std::string expected=it->second;
            lint r=n;
            for(;r&&issymbol(s.at(r-1));r--);
            if(r==0||r<l||r<n-3)ERR;
            std::string result=s.substr(r-expected.size(),expected.size());
            if(!std::all_of(ALL(result),[](char c){return std::isalpha(c);}))ERR
            for(char&c:result){
                c=std::tolower(c);
            }
            if(result!=expected)ERR
        }
        std::cout<<"CORRECT (maybe)"<<'\n';
    }
}
0