結果

問題 No.380 悪の台本
ユーザー hogeover30hogeover30
提出日時 2016-06-18 03:44:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,123 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 79,972 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:32:15
合計ジャッジ時間 2,019 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <map>
#include <cctype>
using namespace std;

map<string, string> suffix;

bool correct(const string& words, const string& name)
{
    if (name=="rabi") {
        for(auto& c: words) if (isalnum(c)) return true;
        return false;
    }
    if (!suffix.count(name)) return false;

    string suf=suffix[name];
    if (words.size()+3<suf.size()) return false;

    int n=words.size();
    for(int i=n-1; i>=n-4; --i) if (isalnum(words[i]))
        return words.substr(i+1-suf.size(), suf.size())==suf;
    return false;
}

int main()
{
    string names[]={"digi", "petit", "gema", "piyo"};
    string suffs[]={"nyo", "nyu", "gema", "pyo"};
    for(int i=0; i<4; ++i) suffix[names[i]]=suffs[i];

    string s;
    while (getline(cin, s)) {
        auto k=s.find(' ');
        if (k!=s.npos) {
            string name=s.substr(0, k);
            string words=s.substr(k+1);
            for(auto& c: words) c=tolower(c);
            cout<<(correct(words, name) ? "CORRECT (maybe)" : "WRONG!")<<endl;
        }
        else {
            cout<<"WRONG!"<<endl;
        }
    }
}
0