結果

問題 No.380 悪の台本
ユーザー naimonon77naimonon77
提出日時 2016-09-02 17:22:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 136 ms / 1,000 ms
コード長 2,493 bytes
コンパイル時間 1,658 ms
コンパイル使用メモリ 169,500 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:47:36
合計ジャッジ時間 2,452 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

bool is_symbol(char c) {
	if (isalpha(c)) return false;
	if (isdigit(c)) return false;
	return true;
}

void print_wrong() {
	puts("WRONG!");
}

void print_ok() {
	puts("CORRECT (maybe)");
}

int stricmp(string l, string r)
{
	int i, j;
	if (l.size() != r.size()) return 1;
	rep(i, l.size()) {
		if (tolower(l[i]) != tolower(r[i])) return 1;
	}
	return 0;
}

string name, words, last;

void judge1() {
	ll i;

	rep(i, 3) {
		if ((ll)words.size() - 1 - i < 0) {
			print_wrong();
			return;
		}
		if (!is_symbol(words[(ll)words.size() - 1 - i])) {
			break;
		}
	}

	if ((ll)words.size() - (ll)last.size() - i < 0) {
		print_wrong();
		return;
	}
	// dump((ll)words.size() - (ll)last.size() - i);

	if (words.substr((ll)words.size() - (ll)last.size() - i).size() < (ll)last.size()) {
		print_wrong();
		return;
	}
	string maybe_last = words.substr((ll)words.size() - (ll)last.size() - i, (ll)last.size());
	//dump(maybe_last);
	if (stricmp(maybe_last, last) == 0) {
		print_ok();
	}
	else {
		print_wrong();
	}
}

signed main(void) {
	ll i, j, k;
	string query;
	while (getline(cin, query)) {
		stringstream ss;
		ss << query;
		
		if (ss.str() == "") {
			print_wrong();
			continue;
		}

		dump(ss.str());

		if (ss.str()[0] == ' ') {
			print_wrong();
			continue;
		}

		ss >> name;
		//dump(name);

		if (ss.str() == "") {
			print_wrong();
			continue;
		}
		getline(ss, words);
		// dump(words);
		ss.clear();
		if (words.size() < 2) {
			print_wrong();
			continue;
		}
		words = words.substr(1);

		if (name == "digi") {
			last = "nyo";
			judge1();
		}
		else if (name == "petit") {
			last = "nyu";
			judge1();
		}
		else if (name == "rabi") {
			rep(i, words.size()) {
				if (not is_symbol(words[i])) {
					print_ok();
					break;
				}
			}
			if (i == words.size()) print_wrong();
		}
		else if (name == "gema") {
			last = "gema";
			judge1();
		}
		else if (name == "piyo") {
			last = "pyo";
			judge1();
		}
		else {
			print_wrong();
		}

	}
}
0