結果
問題 | No.1349 Subset Product Queries |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-28 17:50:47 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 585 bytes |
コンパイル時間 | 5,982 ms |
コンパイル使用メモリ | 254,004 KB |
最終ジャッジ日時 | 2025-01-18 08:31:34 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 30 |
ソースコード
#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+1) 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+1][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;}