結果

問題 No.1349 Subset Product Queries
ユーザー tpynerivertpyneriver
提出日時 2021-01-16 17:29:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,061 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 269,460 KB
最終ジャッジ日時 2023-08-18 15:29:32
合計ジャッジ時間 19,304 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,412 KB
testcase_01 AC 62 ms
71,420 KB
testcase_02 AC 62 ms
71,460 KB
testcase_03 AC 73 ms
76,164 KB
testcase_04 AC 73 ms
76,220 KB
testcase_05 AC 63 ms
71,460 KB
testcase_06 AC 69 ms
76,236 KB
testcase_07 AC 72 ms
76,224 KB
testcase_08 AC 64 ms
71,420 KB
testcase_09 AC 75 ms
76,184 KB
testcase_10 AC 64 ms
71,396 KB
testcase_11 AC 1,061 ms
264,920 KB
testcase_12 AC 935 ms
244,104 KB
testcase_13 AC 941 ms
243,600 KB
testcase_14 AC 971 ms
251,432 KB
testcase_15 AC 983 ms
254,912 KB
testcase_16 AC 1,039 ms
266,524 KB
testcase_17 AC 704 ms
197,616 KB
testcase_18 AC 223 ms
95,124 KB
testcase_19 AC 189 ms
89,980 KB
testcase_20 AC 847 ms
224,116 KB
testcase_21 AC 813 ms
246,076 KB
testcase_22 AC 616 ms
194,532 KB
testcase_23 AC 850 ms
235,108 KB
testcase_24 AC 579 ms
175,228 KB
testcase_25 AC 726 ms
215,628 KB
testcase_26 AC 932 ms
269,460 KB
testcase_27 AC 708 ms
199,212 KB
testcase_28 AC 643 ms
199,160 KB
testcase_29 AC 646 ms
196,548 KB
testcase_30 AC 672 ms
202,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline
    
N, Q, P = map(int, readline().split())
A = list(map(int, readline().split()))
dp = [[-1]*(P+2) for _ in range(N+1)]
dp[0][P+1] = 0
for i in range(N):
    a = A[i]
    for p in range(P+2):
        dp[i+1][p] = max(dp[i+1][p], dp[i][p])
        dp[i+1][p*a%P] = max(dp[i+1][p*a%P], dp[i][p])
    dp[i+1][a] = i+1
    

Ans = [None]*Q
for qu in range(Q):
    l, r, x = map(int, readline().split())
    if dp[r][x] >= l:
        Ans[qu] = 'Yes'
    else:
        Ans[qu] = 'No'

print('\n'.join(Ans))
0