結果

問題 No.380 悪の台本
ユーザー CELICACELICA
提出日時 2020-09-20 20:41:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 1,000 ms
コード長 1,558 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 173,940 KB
実行使用メモリ 4,668 KB
最終ジャッジ日時 2023-09-06 16:31:50
合計ジャッジ時間 2,523 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;

bool isSymbol(const char c)
{
	return (c >= 0x20 && c <= 0x2F) ||
		(c >= 0x3A && c <= 0x40) ||
		(c >= 0x5B && c <= 0x60) ||
		(c >= 0x7B && c <= 0x7E);
}

bool isCorrect(const string s, const string ps)
{
	string sl(s);
	size_t bp = s.size() - ps.size() - 3;
	transform(sl.begin() + bp, sl.end(), sl.begin() + bp, ::tolower);
	size_t p = 1e9;
	for (size_t i = sl.size() - ps.size() - 3; i < sl.size(); ++i)
	{
		if (sl.substr(i, ps.size()) == ps)
		{
			p = i;
			break;
		}
	}

	if (p == 1e9)
		return false;

	for (size_t i = p + ps.size(); i < sl.size(); ++i)
	{
		if (isSymbol(sl[i]))
			continue;
		else
			return false;
	}

	return true;
}

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

	stringstream ss;
	string s;

	vector<pair<string, string> > v = {
		{"digi","nyo"},
		{"petit","nyu"},
		{"rabi",""},
		{"gema","gema"},
		{"piyo","pyo"} };

	while (getline(cin, s))
	{
		bool f{ false };
		for (const auto& it : v)
		{
			if (s.substr(0, 5) == "rabi ")
			{
				for (size_t i = 5; i < s.size(); ++i)
				{
					if (!isSymbol(s[i]))
					{
						f = true;
						break;
					}
				}
			}
			else if (s.substr(0, it.first.size() + 1) == it.first + " ")
			{
				if (s.size() < it.first.size() + it.second.size() + 1)
					continue;
				else if (isCorrect(s, it.second))
				{
					f = true;
					break;
				}
			}

		}
		ss << (f ? "CORRECT (maybe)\n" : "WRONG!\n");
	}
	cout << ss.str();

	return 0;
}
0