結果

問題 No.380 悪の台本
ユーザー pekempeypekempey
提出日時 2016-06-18 00:12:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 136 ms / 1,000 ms
コード長 1,318 bytes
コンパイル時間 1,807 ms
コンパイル使用メモリ 150,320 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 19:45:42
合計ジャッジ時間 2,117 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

string to_lower(string s) {
	for (char &c : s) if (isalpha(c)) c = tolower(c);
	return s;
}

bool is_symbol(char x) {
	return !isalpha(x) && !isdigit(x);
}

pair<string, string> split(string s) {
	int i = 0;
	while (i < s.size() && s[i] != ' ') i++;
	if (i == s.size()) return make_pair("", "");
	return make_pair(s.substr(0, i), s.substr(i + 1));
}

bool is_rabi(string s) {
	if (s.empty()) return false;
	for (char c : s) {
		if (!is_symbol(c)) return true;
	}
	return false;
}

bool check(string s, string tail) {
	for (int i = 0; i < 4; i++) {
		if (s.size() < tail.size()) return false;
		if (s.substr(s.size() - tail.size()) == tail) return true;
		if (!is_symbol(s.back())) return false;
		s.pop_back();
	}
	return false;
}

bool solve(string s) {
	auto v = split(s);
	string t = to_lower(v.second);

	while (t.back() == '\n') t.pop_back();

	if (v.first == "digi") {
		return check(t, "nyo");
	} else if (v.first == "petit") {
		return check(t, "nyu");
	} else if (v.first == "rabi") {
		return is_rabi(t);
	} else if (v.first == "gema") {
		return check(t, "gema");
	} else if (v.first == "piyo") {
		return check(t, "pyo");
	} else {
		return false;
	}
} 

int main() {
	string s;
	while (getline(cin, s)) {
		puts(solve(s) ? "CORRECT (maybe)" : "WRONG!");
	}
}
0