結果
問題 | No.1349 Subset Product Queries |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-28 17:50:06 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 581 bytes |
コンパイル時間 | 7,129 ms |
コンパイル使用メモリ | 251,628 KB |
最終ジャッジ日時 | 2025-01-18 08:31:07 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 WA * 29 |
ソースコード
#include<bits/stdc++.h>using namespace std;using LL=long long;using ULL=unsigned long long;#define rep(i,n) for(int i=0; i<(n); i++)int N,Q,P;int A[5000];int dp[5001][5000];int main(){scanf("%d%d%d",&N,&Q,&P);rep(i,N) scanf("%d",&A[i]);rep(i,N) rep(j,N) dp[i][j]=-1;for(int i=0; i<N; i++){int to=0;dp[i][A[i]]=i;for(int p=0; p<P; p++){dp[i][to]=min(dp[i][p],i);to+=A[i]; if(to>=P) to-=P;}}rep(q,Q){int l,r,k; scanf("%d%d",&l,&r,&k); l--;if(dp[r][k]>=l) printf("Yes\n"); else printf("No\n");}return 0;}