結果

問題 No.380 悪の台本
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-06-18 01:19:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 1,459 bytes
コンパイル時間 1,824 ms
コンパイル使用メモリ 166,648 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-06 19:50:51
合計ジャッジ時間 2,571 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

bool isSymbol(char c)
{
	if ('a' <= c && c <= 'z') return false;
	if ('A' <= c && c <= 'Z') return false;
	if ('0' <= c && c <= '9') return false;
	return true;
}

bool check(string s, string post)
{
	rep(i, 0, 4)
	{
		int st = s.length() - post.length() - i;
		if (st < 0) break;

		string ss = s.substr(st);
		//cout << ss << "," << post << endl;
		
		bool halt = false;
		rep(j, 0, post.length())
		{
			if (ss[j] != post[j] && ss[j] != ('A' + post[j] - 'a')) halt = true;
		}
		if (halt) continue;

		halt = false;
		rep(j, 0, i)
		{
			if (!isSymbol(ss[post.length() + j])) halt = true;
		}
		if (halt) continue;

		return true;
	}

	return false;
}

bool check2(string s)
{
	rep(i, 0, s.length()) if (!isSymbol(s[i])) return true;
	return false;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	while (getline(cin, s))
	{
		bool ans = false;

		if (5 < s.length())
		{
			if (s.substr(0, 5) == "digi ")
				ans = check(s.substr(5), "nyo");
			else if (s.substr(0, 6) == "petit ")
				ans = check(s.substr(6), "nyu");
			else if (s.substr(0, 5) == "rabi ")
				ans = check2(s.substr(5));
			else if (s.substr(0, 5) == "gema ")
				ans = check(s.substr(5), "gema");
			else if (s.substr(0, 5) == "piyo ")
				ans = check(s.substr(5), "pyo");
		}

		if (ans)
			printf("CORRECT (maybe)\n");
		else
			printf("WRONG!\n");
	}
}
0