結果

問題 No.1349 Subset Product Queries
ユーザー ace_amuroace_amuro
提出日時 2022-04-13 18:36:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 79,936 KB
実行使用メモリ 101,288 KB
最終ジャッジ日時 2023-08-25 10:37:14
合計ジャッジ時間 9,136 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 218 ms
94,364 KB
testcase_12 AC 196 ms
84,148 KB
testcase_13 AC 193 ms
84,016 KB
testcase_14 AC 218 ms
95,932 KB
testcase_15 AC 192 ms
89,500 KB
testcase_16 AC 208 ms
94,824 KB
testcase_17 AC 156 ms
83,152 KB
testcase_18 AC 92 ms
87,996 KB
testcase_19 AC 95 ms
87,868 KB
testcase_20 AC 182 ms
98,796 KB
testcase_21 AC 190 ms
101,288 KB
testcase_22 AC 167 ms
98,620 KB
testcase_23 AC 189 ms
101,100 KB
testcase_24 AC 148 ms
100,048 KB
testcase_25 AC 173 ms
100,880 KB
testcase_26 AC 205 ms
101,180 KB
testcase_27 AC 163 ms
100,552 KB
testcase_28 AC 162 ms
100,552 KB
testcase_29 AC 162 ms
100,608 KB
testcase_30 AC 165 ms
100,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int MR=5005;
int Q,n,p,a[MR],dp[MR][MR];
int L,R,K;
int main(){
    scanf("%d%d%d",&n,&Q,&p);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=1;i<=n;i++){
        dp[i][a[i]%p]=i;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<p;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            dp[i+1][j*a[i+1]%p]=max(dp[i+1][j*a[i+1]%p],dp[i][j]);
        }
    }
    // for(int j=0;j<p;j++)printf("%2d",j);printf("\n");
    // for(int i=1;i<=n;i++){
    //     for(int j=0;j<p;j++)printf("%2d",dp[i][j]);printf("\n");
    // }
    for(;Q>0;Q--){
        scanf("%d%d%d",&L,&R,&K);
        if(dp[R][K]>=L){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}
0