結果

問題 No.1349 Subset Product Queries
ユーザー 👑 hitonanodehitonanode
提出日時 2021-05-14 02:28:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 459 ms / 2,000 ms
コード長 871 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 78,016 KB
実行使用メモリ 96,256 KB
最終ジャッジ日時 2024-04-08 13:39:34
合計ジャッジ時間 10,601 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 452 ms
93,952 KB
testcase_12 AC 413 ms
83,968 KB
testcase_13 AC 407 ms
83,840 KB
testcase_14 AC 371 ms
87,680 KB
testcase_15 AC 433 ms
89,216 KB
testcase_16 AC 459 ms
94,720 KB
testcase_17 AC 282 ms
60,928 KB
testcase_18 AC 96 ms
9,728 KB
testcase_19 AC 80 ms
6,912 KB
testcase_20 AC 370 ms
73,984 KB
testcase_21 AC 308 ms
85,120 KB
testcase_22 AC 245 ms
59,520 KB
testcase_23 AC 295 ms
79,488 KB
testcase_24 AC 208 ms
49,536 KB
testcase_25 AC 256 ms
70,016 KB
testcase_26 AC 331 ms
96,256 KB
testcase_27 AC 242 ms
61,824 KB
testcase_28 AC 231 ms
61,824 KB
testcase_29 AC 251 ms
60,416 KB
testcase_30 AC 251 ms
63,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template <typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);
    int N, Q, P;
    cin >> N >> Q >> P;
    vector<int> A(N);
    for (auto &a : A) cin >> a;
    vector dp(N + 1, vector<int>(P, N));

    IREP(i, N) {
        dp[i] = dp[i + 1];
        chmin(dp[i][A[i]], i);
        REP(j, P) chmin(dp[i][A[i] * j % P], dp[i + 1][j]);
    }
    while (Q--) {
        int L, R, K;
        cin >> L >> R >> K;
        L--;
        cout << (dp[L][K] < R ? "Yes" : "No") << '\n';
    }
}
0