結果

問題 No.380 悪の台本
ユーザー kurenai3110kurenai3110
提出日時 2016-07-05 17:59:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,374 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 57,564 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:38:42
合計ジャッジ時間 987 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 17 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 4 ms
5,376 KB
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘bool solve(std::string, std::string)’:
main.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

bool a[127];
bool solve(string script, string gobi);

int main() {
	for (int i = 32; i < 127; i++){
		if (i < 48) a[i] = true;
		else if (i >= 58 && i <= 64) a[i] = true;
		else if (i >= 91 && i <= 96) a[i] = true;
		else if (i >= 123) a[i] = true;
	}
	string name;
	
	while (cin >> name){
		string script;
		getline(cin, script);
		string gobi;
		if (name == "digi") gobi = "nyo";
		else if (name == "petit") gobi = "nyu";
		else if (name == "rabi"){
			for (int i = 0; i < script.size(); i++){
				if (!a[script[i]]) {
					cout << "CORRECT (maybe)" << endl;
					break;
				}
				if (i == script.size() - 1) cout << "WRONG!" << endl;
			}
			continue;
		}
		else if (name == "gema") gobi = "gema";
		else if (name == "piyo") gobi = "pyo";
		else cout << "WRONG!" << endl;

		bool b;
		b=solve(script, gobi);
		if (b) cout << "CORRECT (maybe)" << endl;
		else cout << "WRONG!" << endl;
	}
	return 0;
}

bool solve(string script, string gobi){
	int cnt=0;
	for (int i = 1; i < 7; i++){
		if (a[script[script.size() - i]]){
			cnt++;
			if (cnt > 3) return false;
		}
		else{
			for (int j = 0; j < gobi.size();j++){
				if (script[script.size() - i - gobi.size() + 1 + j] != gobi[j] &&
					script[script.size() - i - gobi.size() + 1 + j] != gobi[j] - 32){
					return false;
				}
			}
			return true;
		}
	}
}

0