結果

問題 No.1349 Subset Product Queries
ユーザー KoDKoD
提出日時 2021-01-15 14:47:43
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,262 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 264,372 KB
最終ジャッジ日時 2023-08-17 06:09:17
合計ジャッジ時間 21,741 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,504 KB
testcase_01 AC 71 ms
71,572 KB
testcase_02 AC 74 ms
71,392 KB
testcase_03 AC 82 ms
76,160 KB
testcase_04 AC 85 ms
76,292 KB
testcase_05 AC 72 ms
71,128 KB
testcase_06 AC 76 ms
76,160 KB
testcase_07 AC 84 ms
76,160 KB
testcase_08 AC 73 ms
71,392 KB
testcase_09 AC 87 ms
76,196 KB
testcase_10 AC 75 ms
71,456 KB
testcase_11 AC 1,262 ms
258,868 KB
testcase_12 AC 1,149 ms
239,616 KB
testcase_13 AC 1,128 ms
239,516 KB
testcase_14 AC 1,168 ms
246,692 KB
testcase_15 AC 1,198 ms
249,984 KB
testcase_16 AC 1,259 ms
260,572 KB
testcase_17 AC 860 ms
193,652 KB
testcase_18 AC 260 ms
90,600 KB
testcase_19 AC 227 ms
84,920 KB
testcase_20 AC 1,004 ms
219,312 KB
testcase_21 AC 981 ms
241,924 KB
testcase_22 AC 705 ms
190,208 KB
testcase_23 AC 986 ms
230,444 KB
testcase_24 AC 678 ms
170,872 KB
testcase_25 AC 837 ms
211,024 KB
testcase_26 AC 1,091 ms
264,372 KB
testcase_27 AC 772 ms
194,656 KB
testcase_28 AC 763 ms
195,080 KB
testcase_29 AC 748 ms
192,800 KB
testcase_30 AC 780 ms
198,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

N, Q, P = map(int, input().split())
A = list(map(int, input().split()))

dp = [[-1] * P for _ in range(N + 1)]
for i in range(N):
  for j in range(P):
    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
    dp[i + 1][(j * A[i]) % P] = max(dp[i + 1][(j * A[i]) % P], dp[i][j])
  dp[i + 1][A[i]] = i

for _ in range(Q):
  l, r, k = map(int, input().split())
  l -= 1
  if dp[r][k] >= l:
    print("Yes")
  else:
    print("No")
0