結果
| 問題 |
No.1349 Subset Product Queries
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-01-28 17:51:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 600 bytes |
| コンパイル時間 | 1,902 ms |
| コンパイル使用メモリ | 194,156 KB |
| 最終ジャッジ日時 | 2025-01-18 08:31:48 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:22: warning: too many arguments for format [-Wformat-extra-args]
24 | int l,r,k; scanf("%d%d",&l,&r,&k); l--;
| ^~~~~~
main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d%d%d",&N,&Q,&P);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:13:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | rep(i,N) scanf("%d",&A[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:24:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | int l,r,k; scanf("%d%d",&l,&r,&k); l--;
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#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]=max(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;
}
Nachia