結果

問題 No.1349 Subset Product Queries
ユーザー 00 Sakuda00 Sakuda
提出日時 2024-03-30 18:44:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 628 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 3,238 ms
コンパイル使用メモリ 206,776 KB
実行使用メモリ 96,128 KB
最終ジャッジ日時 2024-03-30 18:44:51
合計ジャッジ時間 17,766 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 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 1 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 617 ms
94,080 KB
testcase_12 AC 621 ms
84,224 KB
testcase_13 AC 594 ms
84,096 KB
testcase_14 AC 600 ms
87,552 KB
testcase_15 AC 628 ms
89,472 KB
testcase_16 AC 617 ms
94,976 KB
testcase_17 AC 568 ms
60,928 KB
testcase_18 AC 447 ms
9,984 KB
testcase_19 AC 424 ms
7,040 KB
testcase_20 AC 598 ms
73,984 KB
testcase_21 AC 614 ms
85,120 KB
testcase_22 AC 551 ms
59,520 KB
testcase_23 AC 607 ms
79,488 KB
testcase_24 AC 529 ms
49,536 KB
testcase_25 AC 591 ms
70,016 KB
testcase_26 AC 620 ms
96,128 KB
testcase_27 AC 576 ms
61,824 KB
testcase_28 AC 567 ms
61,824 KB
testcase_29 AC 585 ms
60,416 KB
testcase_30 AC 578 ms
63,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace atcoder;
using namespace std;
using ll = long long;
int main() {
	int N, Q, P;cin >> N >> Q >> P;
	vector<vector<int>> dp(N + 1, vector<int>(P, 0));
	vector<int> A(N + 1);
	for (int i = 1;i <= N;i++) cin >> A[i];
	dp[1][A[1]] = 1;
	for (int i = 1;i < N;i++) {
		int nxt = A[i + 1];
		for (int j = 0;j < P;j++) dp[i + 1][(j * nxt) % P] = max(dp[i + 1][(j * nxt) % P], dp[i][j]);
		for (int j = 0;j < P;j++) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
	       dp[i + 1][nxt] = max(dp[i + 1][nxt], i + 1);	
	}
	while (Q--) {
		int l, r, k;cin >> l >>r >> k;
		cout << (dp[r][k] >= l ? "Yes" : "No") << endl;
	}
}

0