結果

問題 No.1349 Subset Product Queries
ユーザー hitonanode
提出日時 2021-05-14 02:28:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 606 ms / 2,000 ms
コード長 871 bytes
コンパイル時間 1,111 ms
コンパイル使用メモリ 77,044 KB
最終ジャッジ日時 2025-01-21 10:50:51
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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