結果

問題 No.1349 Subset Product Queries
ユーザー 👑 SPD_9X2
提出日時 2025-08-31 23:56:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 894 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 274,796 KB
最終ジャッジ日時 2025-08-31 23:56:49
合計ジャッジ時間 16,862 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/1349

Rを決め撃った時、必要なLの最小値をあらかじめ求めておく

"""

import sys
from sys import stdin

N,Q,P = map(int,stdin.readline().split())

A = list(map(int,stdin.readline().split()))

dp = [ [0] * P ]

for i in range(N):

    ndp = [x for x in dp[-1]]
    ndp[A[i]] = i+1

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

    dp.append(ndp)

ANS = []

for loop in range(Q):

    L,R,K = map(int,stdin.readline().split())

    if dp[R][K] >= L:
        ANS.append("Yes")
    else:
        ANS.append("No")

print (*ANS,sep="\n")
    
0