結果

問題 No.1349 Subset Product Queries
ユーザー 👑 deuteridayodeuteridayo
提出日時 2021-01-17 03:28:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 810 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 1,864 ms
コンパイル使用メモリ 171,212 KB
実行使用メモリ 100,608 KB
最終ジャッジ日時 2024-05-06 16:41:34
合計ジャッジ時間 17,970 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 810 ms
98,432 KB
testcase_12 AC 713 ms
88,576 KB
testcase_13 AC 716 ms
88,576 KB
testcase_14 AC 731 ms
92,160 KB
testcase_15 AC 731 ms
93,824 KB
testcase_16 AC 771 ms
99,200 KB
testcase_17 AC 630 ms
65,408 KB
testcase_18 AC 433 ms
14,336 KB
testcase_19 AC 415 ms
11,520 KB
testcase_20 AC 721 ms
78,592 KB
testcase_21 AC 768 ms
89,600 KB
testcase_22 AC 625 ms
64,128 KB
testcase_23 AC 683 ms
84,224 KB
testcase_24 AC 598 ms
54,144 KB
testcase_25 AC 654 ms
74,624 KB
testcase_26 AC 744 ms
100,608 KB
testcase_27 AC 628 ms
66,432 KB
testcase_28 AC 663 ms
66,304 KB
testcase_29 AC 623 ms
64,896 KB
testcase_30 AC 674 ms
67,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using lint = long long;
#define endl '\n'
lint const mod = 1e9+7;
//long const mod = 998244353;


int main(){
    lint n,q,p;
    cin >> n >> q >> p;
    lint a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    lint l[q];
    lint r[q];
    lint k[q];
    vector<vector<int>>dp(n+1,vector<int>(p,-1));
    dp[0][1] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<p;j++){
            dp[i+1][(j * a[i]) % p] = max({dp[i][j], dp[i][(j*a[i])%p], dp[i+1][(j * a[i]%p)]});
            dp[i+1][j] = max({dp[i][j],dp[i+1][j]});
        }
        dp[i+1][a[i]] = i+1;
    }
    for(int i=0;i<q;i++){
        cin >> l[i] >> r[i] >> k[i];
        if(dp[r[i]][k[i]] >= l[i])cout << "Yes" << endl;
        else cout << "No"<<endl;
    }
}
0