結果
| 問題 |
No.1349 Subset Product Queries
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-16 14:31:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 861 ms / 2,000 ms |
| コード長 | 616 bytes |
| コンパイル時間 | 335 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 113,912 KB |
| 最終ジャッジ日時 | 2024-11-27 16:12:55 |
| 合計ジャッジ時間 | 16,115 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
import sys
input = sys.stdin.readline
N,Q,P = map(int,input().split())
A = list(map(int,input().split()))
query_r = [[] for i in range(N)]
ans = ["No" for i in range(Q)]
for i in range(Q):
l,r,k = map(int,input().split())
query_r[r-1].append((l-1,k,i))
dp = [-1 for i in range(P)]
for r in range(N):
new_dp = [dp[i] for i in range(P)]
for i in range(P):
if dp[i]!=-1:
to = (i*A[r]) % P
new_dp[to] = max(new_dp[to],dp[i])
new_dp[A[r]] = r
dp = new_dp
for l,k,idx in query_r[r]:
if dp[k] >= l:
ans[idx] = "Yes"
print(*ans,sep="\n")