結果

問題 No.1349 Subset Product Queries
ユーザー penguinmanpenguinman
提出日時 2021-02-11 06:16:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,534 bytes
コンパイル時間 2,683 ms
コンパイル使用メモリ 220,548 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-23 03:21:16
合計ジャッジ時間 7,087 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define ALL(a) (a).begin(),(a).end()
#define pb emplace_back
#define mp std::make_pair
//
#define endl "\n"
//using std::endl;
using std::cin;
using std::cout;
using ll=short;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
vii dp;
vector<vii> mem;
vi A;
ll dfs(ll now,ll val){
    if(dp[now][val]!=-1) return dp[now][val];
    if(now==0) return 0;
    if(A[now-1]==val) return now;
    dp[now][val]=std::max(dp[now][val],dfs(now-1,val));
    for(auto p:mem[A[now-1]][val]) dp[now][val]=std::max(dp[now][val],dfs(now-1,p));
    return dp[now][val];
}
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::random_device rnd;
    std::mt19937 mt(rnd());
    ll N,Q,P; cin>>N>>Q>>P;
    A.resize(N);
    rep(i,0,N) cin>>A[i];
    dp.resize(N+1,vi(P,-1));
    mem.resize(P,vii(P));
    rep(i,0,P){
        rep(j,0,P) mem[i][(int)i*j%P].pb(j);
    }
    while(Q--){
        ll L,R,K; cin>>L>>R>>K;
        string ans="No";
        if(dfs(R,K)>=L) ans="Yes";
        cout<<ans<<endl;
    }
}
0