結果

問題 No.380 悪の台本
ユーザー dgd1724dgd1724
提出日時 2016-11-11 07:04:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 141 ms / 1,000 ms
コード長 1,922 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 166,396 KB
実行使用メモリ 7,708 KB
最終ジャッジ日時 2024-04-24 14:51:27
合計ジャッジ時間 2,278 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

inline std::vector<std::string> Split_String(const std::string &str, const char key) {

	std::vector<std::string> result;
	std::stringstream SS(str);
	std::string temp;

	while (std::getline(SS, temp, key)) {
		result.push_back(temp);
	}

	return(result);

}
int main(void) {

	//std::ifstream inf("123.txt");	std::cin.rdbuf(inf.rdbuf());
	
	std::string str;
	while (std::getline(std::cin, str)) {

		if (str == "") { 
			std::cout << "WRONG!" << std::endl;
			continue;
		}

		std::vector<std::string> split = Split_String(str, ' ');
		if (split.size() < 2) {
			std::cout << "WRONG!" << std::endl;
			continue;
		}

		std::string ed;
		if (split[0] == "digi") { ed = "nyo"; }
		else if (split[0] == "petit") { ed = "nyu"; }
		else if (split[0] == "rabi") { ed = "rabi"; }
		else if (split[0] == "gema") { ed = "gema"; }
		else if (split[0] == "piyo") { ed = "pyo"; }
		else {
			std::cout << "WRONG!" << std::endl;
			continue;
		}

		str.erase(str.begin(), str.begin() + split[0].length() + 1);
		std::transform(str.begin(), str.end(), str.begin(), tolower);

		bool flg = false;
		if (ed == "rabi") {
			for (unsigned int i = 0; i < str.length(); i++) {
				if (std::isalpha(str[i]) || std::isdigit(str[i])) {
					flg = true;
					break;
				}
			}
		}
		else {
			unsigned int found = str.rfind(ed);
			if (found != std::string::npos) {
				if (str.length() - found - ed.length() <= 3) {
					flg = true;
					for (unsigned int i = found + ed.length(); i < str.length(); i++) {
						if (std::isalpha(str[i]) || std::isdigit(str[i])) {
							flg = false;
							break;
						}
					}
				}
			}
		}

		if (flg) { std::cout << "CORRECT (maybe)" << std::endl; }
		else { std::cout << "WRONG!" << std::endl; }

	}

}

0