結果

問題 No.1349 Subset Product Queries
ユーザー chocoruskchocorusk
提出日時 2021-01-19 20:18:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 631 ms / 2,000 ms
コード長 1,085 bytes
コンパイル時間 1,160 ms
コンパイル使用メモリ 128,888 KB
実行使用メモリ 102,088 KB
最終ジャッジ日時 2024-05-09 22:30:39
合計ジャッジ時間 15,315 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 548 ms
94,976 KB
testcase_12 AC 631 ms
84,736 KB
testcase_13 AC 535 ms
84,736 KB
testcase_14 AC 531 ms
96,768 KB
testcase_15 AC 542 ms
90,112 KB
testcase_16 AC 546 ms
95,744 KB
testcase_17 AC 501 ms
76,928 KB
testcase_18 AC 431 ms
27,264 KB
testcase_19 AC 434 ms
24,448 KB
testcase_20 AC 533 ms
93,568 KB
testcase_21 AC 544 ms
102,088 KB
testcase_22 AC 514 ms
79,360 KB
testcase_23 AC 537 ms
99,584 KB
testcase_24 AC 492 ms
69,376 KB
testcase_25 AC 524 ms
89,856 KB
testcase_26 AC 551 ms
102,000 KB
testcase_27 AC 514 ms
81,664 KB
testcase_28 AC 511 ms
81,664 KB
testcase_29 AC 514 ms
80,256 KB
testcase_30 AC 514 ms
83,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int dp[5050][5050];

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