結果

問題 No.380 悪の台本
ユーザー mamekinmamekin
提出日時 2016-07-18 17:37:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 1,762 bytes
コンパイル時間 904 ms
コンパイル使用メモリ 104,196 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:42:26
合計ジャッジ時間 1,612 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(;;){
        string s;
        if(!getline(cin, s))
            break;
        int n = s.size();

        int k = 0;
        while(k < n && s[k] != ' ')
            ++ k;

        string name = s.substr(0, k);
        s = s.substr(k);
        n = s.size();

        for(int i=0; i<n; ++i)
            s[i] = tolower(s[i]);

        bool correct = false;
        if(name == "rabi"){
            for(int i=0; i<n; ++i){
                if(isdigit(s[i]) || isalpha(s[i]))
                    correct = true;
            }
        }
        else{
            string gobi;
            if(name == "digi")
                gobi = "nyo";
            else if(name == "petit")
                gobi = "nyu";
            else if(name == "gema")
                gobi = "gema";
            else if(name == "piyo")
                gobi = "pyo";

            if(gobi.size() != 0){
                int i = n - 1;
                while(i >= 0 && !isdigit(s[i]) && !isalpha(s[i]))
                    -- i;

                if(n - 1 - i <= 3 && i - (int)gobi.size() + 1 >= 0 && s.substr(i - gobi.size() + 1, gobi.size()) == gobi)
                    correct = true;
            }
        }

        if(correct)
            cout << "CORRECT (maybe)" << endl;
        else
            cout << "WRONG!" << endl;
    }

    return 0;
}
0