結果

問題 No.1349 Subset Product Queries
ユーザー V_Melville
提出日時 2024-11-13 11:09:43
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 686 bytes
コンパイル時間 3,120 ms
コンパイル使用メモリ 249,236 KB
実行使用メモリ 10,148 KB
最終ジャッジ日時 2024-11-13 11:09:53
合計ジャッジ時間 9,080 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

int main() {
    int n, q, p;
    cin >> n >> q >> p;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    rep(qi, q) {
        int l, r, k;
        cin >> l >> r >> k;
        --l;
        
        vector<bool> dp(p);
        for (int i = l; i < r; ++i) {
            vector<bool> old(p);
            swap(dp, old);
            
            rep(j, p) if (old[j]) {
                dp[j] = true;
                dp[(j*a[i])%p] = true;
            }
            dp[a[i]] = true;
        }
        
        if (dp[k]) puts("Yes");
        else puts("No");
    }
    
    return 0;
}
0