結果

問題 No.380 悪の台本
ユーザー hogeover30hogeover30
提出日時 2016-06-18 01:19:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 995 bytes
コンパイル時間 820 ms
コンパイル使用メモリ 79,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:30:41
合計ジャッジ時間 1,555 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
    }

    int n=words.size();
    auto k=words.find_last_of(suffix[name]);

    if (k==string::npos) return false;
    if (k<n-3) return false;
    for(int i=k+1; i<n; ++i) if (isalnum(words[i])) return false;
    return true;
}

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)) {
        string name=s.substr(0, s.find(' '));
        string words=s.substr(s.find(' ')+1);
        for(auto& c: words) c=tolower(c);

        if (correct(words, name))
            cout<<"CORRECT (maybe)"<<endl;
        else
            cout<<"WRONG!"<<endl;
    }
}
0