結果

問題 No.1349 Subset Product Queries
ユーザー milanis48663220milanis48663220
提出日時 2021-05-10 22:50:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 672 ms / 2,000 ms
コード長 1,369 bytes
コンパイル時間 1,683 ms
コンパイル使用メモリ 119,712 KB
実行使用メモリ 101,372 KB
最終ジャッジ日時 2023-10-20 08:07:29
合計ジャッジ時間 16,875 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
5,784 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
5,792 KB
testcase_04 AC 2 ms
5,796 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
5,788 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 3 ms
5,804 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 672 ms
94,236 KB
testcase_12 AC 615 ms
84,156 KB
testcase_13 AC 608 ms
84,228 KB
testcase_14 AC 574 ms
96,000 KB
testcase_15 AC 632 ms
89,568 KB
testcase_16 AC 655 ms
96,448 KB
testcase_17 AC 501 ms
78,692 KB
testcase_18 AC 354 ms
43,588 KB
testcase_19 AC 335 ms
24,580 KB
testcase_20 AC 582 ms
96,140 KB
testcase_21 AC 513 ms
101,368 KB
testcase_22 AC 475 ms
84,624 KB
testcase_23 AC 505 ms
100,044 KB
testcase_24 AC 434 ms
76,980 KB
testcase_25 AC 477 ms
92,700 KB
testcase_26 AC 546 ms
101,372 KB
testcase_27 AC 459 ms
86,364 KB
testcase_28 AC 448 ms
86,396 KB
testcase_29 AC 470 ms
85,292 KB
testcase_30 AC 469 ms
87,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;
const int INF = 1e9;

int dp[5005][5005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, q, p; cin >> n >> q >> p;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < p; j++){
            dp[i][j] = -INF;
        }
    }
    dp[0][a[0]] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < p; j++) dp[i][j] = dp[i-1][j];
        dp[i][a[i]] = i;
        for(int j = 0; j < p; j++){
            chmax(dp[i][(j*a[i])%p], dp[i-1][j]);
        }
    }
    while(q--){
        int l, r, k; cin >> l >> r >> k; l--; r--;
        cout << (dp[r][k] >= l ? "Yes" : "No") << endl;
    }
}
0