結果

問題 No.1349 Subset Product Queries
ユーザー tpynerivertpyneriver
提出日時 2021-01-16 17:29:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,101 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,028 KB
実行使用メモリ 268,780 KB
最終ジャッジ日時 2024-05-05 20:40:07
合計ジャッジ時間 18,620 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,224 KB
testcase_01 AC 40 ms
52,480 KB
testcase_02 AC 42 ms
52,736 KB
testcase_03 AC 47 ms
61,312 KB
testcase_04 AC 49 ms
62,528 KB
testcase_05 AC 38 ms
52,736 KB
testcase_06 AC 42 ms
59,136 KB
testcase_07 AC 47 ms
61,952 KB
testcase_08 AC 37 ms
52,352 KB
testcase_09 AC 50 ms
62,848 KB
testcase_10 AC 38 ms
52,480 KB
testcase_11 AC 1,101 ms
264,468 KB
testcase_12 AC 994 ms
243,072 KB
testcase_13 AC 965 ms
242,432 KB
testcase_14 AC 977 ms
250,240 KB
testcase_15 AC 1,085 ms
253,512 KB
testcase_16 AC 1,083 ms
265,944 KB
testcase_17 AC 764 ms
196,820 KB
testcase_18 AC 230 ms
94,132 KB
testcase_19 AC 197 ms
88,640 KB
testcase_20 AC 887 ms
222,848 KB
testcase_21 AC 838 ms
244,928 KB
testcase_22 AC 635 ms
193,464 KB
testcase_23 AC 844 ms
233,728 KB
testcase_24 AC 603 ms
173,952 KB
testcase_25 AC 734 ms
214,552 KB
testcase_26 AC 945 ms
268,780 KB
testcase_27 AC 727 ms
198,060 KB
testcase_28 AC 686 ms
198,016 KB
testcase_29 AC 668 ms
195,200 KB
testcase_30 AC 671 ms
201,600 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