結果

問題 No.1349 Subset Product Queries
ユーザー chocoruskchocorusk
提出日時 2021-01-19 20:18:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 1,085 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 127,616 KB
実行使用メモリ 102,308 KB
最終ジャッジ日時 2023-08-22 16:42:24
合計ジャッジ時間 16,222 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 539 ms
94,920 KB
testcase_12 AC 526 ms
84,788 KB
testcase_13 AC 517 ms
84,940 KB
testcase_14 AC 525 ms
96,680 KB
testcase_15 AC 536 ms
90,024 KB
testcase_16 AC 540 ms
95,616 KB
testcase_17 AC 497 ms
82,640 KB
testcase_18 AC 429 ms
82,156 KB
testcase_19 AC 418 ms
81,812 KB
testcase_20 AC 513 ms
99,140 KB
testcase_21 AC 536 ms
102,012 KB
testcase_22 AC 504 ms
96,312 KB
testcase_23 AC 521 ms
101,544 KB
testcase_24 AC 477 ms
94,056 KB
testcase_25 AC 525 ms
99,208 KB
testcase_26 AC 553 ms
102,308 KB
testcase_27 AC 504 ms
97,552 KB
testcase_28 AC 505 ms
97,368 KB
testcase_29 AC 509 ms
97,188 KB
testcase_30 AC 506 ms
97,820 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