結果

問題 No.380 悪の台本
ユーザー femtofemto
提出日時 2016-08-22 04:39:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 1,000 ms
コード長 1,637 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 81,096 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:44:28
合計ジャッジ時間 1,336 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 AC 4 ms
5,376 KB
testcase_05 AC 13 ms
5,376 KB
testcase_06 AC 15 ms
5,376 KB
testcase_07 AC 115 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;

bool isSymbol(char c) {
	return !('0' <= c && c <= '9') && !('a' <= c && c <= 'z');
}

bool check(string s, string gobi) {
	if(s.size() < gobi.size()) return false;
	for(int i = 0; i <= 3; i++) {
		if(s.size() < gobi.size() + i) continue;

		if(s.substr(s.size() - gobi.size() - i, gobi.size()) != gobi)
			continue;
		bool flag = true;
		for(int j = 0; j < i; j++) {
			int p = s.size() - 1 - j;
			if(!isSymbol(s[p])) {
				flag = false;
				break;
			}
		}
		if(flag) return true;
	}
	return false;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string name, s, t;

	while(getline(cin, t)) {

		bool ok = false;
		if(t.size() >= 5 && t[4] == ' ') {
			name = t.substr(0, 4);
			s = t.substr(5);
			for(int i = 0; i < s.size(); i++) {
				if('A' <= s[i] && s[i] <= 'Z')
					s[i] = tolower(s[i]);
			}
			if(name == "digi") {
				ok = check(s, "nyo");
			}
			if(name == "rabi") {
				for(int i = 0; i < s.size(); i++) {
					if(!isSymbol(s[i])) {
						ok = true;
					}
				}
			}
			if(name == "gema") {
				ok = check(s, "gema");
			}
			if(name == "piyo") {
				ok = check(s, "pyo");
			}
		}
		if(t.size() >= 6 && t[5] == ' ') {
			name = t.substr(0, 5);
			s = t.substr(5);
			for(int i = 0; i < s.size(); i++) {
				if('A' <= s[i] && s[i] <= 'Z')
					s[i] = tolower(s[i]);
			}
			if(name == "petit") {
				ok = check(s, "nyu");
			}
		}

		if(ok) {
			cout << "CORRECT (maybe)" << endl;
		}
		else {
			cout << "WRONG!" << endl;
		}
	}
}
0