結果

問題 No.380 悪の台本
ユーザー antaanta
提出日時 2016-06-18 00:21:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 1,605 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 169,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:27:39
合計ジャッジ時間 2,187 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

bool myissymbol(char c) {
	return !isalnum(c);
}
int main() {
	const vector<pair<string, string>> list = {
		{ "digi", "nyo" },
		{ "petit", "nyu" },
		{ "rabi", "" },
		{ "gema", "gema" },
		{ "piyo", "pyo" }
	};
	char *buf = new char[100 * 1024 + 3];
	while(fgets(buf, 100 * 1024 + 2, stdin) && !feof(stdin)) {
		string s = buf;
		if(s.back() == '\n') s.pop_back();
		bool wrong = true;
		for(const auto &p : list) {
			if(s.size() < p.first.size() + 1 || s.substr(0, p.first.size() + 1) != p.first + ' ')
				continue;
			auto t = s.substr(p.first.size() + 1);
			bool ok = false;
			if(p.first == "rabi") {
				for(char c : t)
					ok |= !myissymbol(c);
			} else {
				rer(k, 0, 3) {
					if(t.size() < p.second.size() + k) continue;
					bool a = true;
					rep(i, p.second.size())
						a &= tolower(t[t.size() - k - p.second.size() + i]) == p.second[i];
					rep(i, k) a &= myissymbol(t[t.size() - 1 - i]);
					ok |= a;
				}
			}
			wrong &= !ok;
		}
		puts(wrong ? "WRONG!" : "CORRECT (maybe)");
	}
	return 0;
}
0