結果

問題 No.380 悪の台本
ユーザー FF256grhyFF256grhy
提出日時 2016-06-18 01:12:31
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,531 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 27,672 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 19:50:04
合計ジャッジ時間 862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>

char str[102400];
int i;

bool eq(int pos, int len, const char* const t) {
	if( ! (pos + len <= i) ) { return false; }
	for(int j = 0; j < len; j++) {
		if(str[pos + j] != t[j]) { return false; }
	}
	
	return true;
}

bool eq_2(int pos, int len, const char* const t) {
	if( ! (pos + len <= i) ) { return false; }
	for(int j = 0; j < len; j++) {
		char a = str[pos + j], b = t[j];
		if( ! (a == b || a + ('a' - 'A') == b) ) { return false; }
	}
	
	return true;
}

bool is_sym(int j) {
	char c = str[j];
	if(
		('a' <= c && c <= 'z') ||
		('A' <= c && c <= 'Z') ||
		('0' <= c && c <= '9')
	) { return false; }
	
	return true;
}

bool f(const char* const t, int j, const char* const u, int k) {
	if( ! eq(0, j, t) ) { return false; }
	
	for(int l = 0; l < 4; l++) {
		bool flag = eq_2(i - (k + l), k, u);
		for(int m = 0; m < l; m++) {
			flag = flag && is_sym(i - l + m);
		}
		if(flag) { return true; }
	}
	return false;
}

bool d() {
	return f("digi ", 5, "nyo", 3);
}

bool pe() {
	return f("petit ", 6, "nyu", 3);
}

bool g() {
	return f("gema ", 5, "gema", 4);
}

bool pi() {
	return f("piyo ", 5, "pyo", 3);
}

bool r() {
	if( ! eq(0, 5, "rabi ") ) { return false; }
	for(int j = 5; j < i; j++) {
		if( ! is_sym(j) ) { return true; }
	}
	
	return false;
}

int main() {
	i = 0;
	while(true) {
		str[i] = getchar();
		if(str[i] == EOF) { break; }
		if(str[i] == '\n') {
			printf("%s\n", d() || pe() || g() || pi() || r() ? "CORRECT (maybe)" : "WRONG!");
			i = 0;
			continue;
		}
		i++;
	}
	
	return 0;
}
0