結果

問題 No.2535 多重同値
ユーザー Today03Today03
提出日時 2023-11-10 22:01:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 515 bytes
コンパイル時間 2,552 ms
コンパイル使用メモリ 211,840 KB
実行使用メモリ 121,876 KB
最終ジャッジ日時 2023-11-10 22:01:41
合計ジャッジ時間 6,590 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,480 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 448 ms
34,944 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<bool> P(N + 1);
	for (int i = 1; i <= N; i++) {
		string s;
		cin >> s;
		P[i] = s == "Yes";
	}
	map<pair<int, int>, bool> memo;
	auto X = [&](auto&& X, int l, int r) -> bool {
		if (l == r) {
			return P[l];
		}
		if (memo.count(make_pair(l, r))) {
			return memo[make_pair(l, r)];
		}
		return memo[make_pair(l, r)] = P[l] == X(X, l + 1, r);
	};
	for (int i = 1; i <= N; i++) {
		cout << (X(X, 1, i) ? "Yes\n" : "No\n");
	}
}
0