結果
問題 |
No.1349 Subset Product Queries
|
ユーザー |
![]() |
提出日時 | 2021-02-11 06:21:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,546 bytes |
コンパイル時間 | 2,109 ms |
コンパイル使用メモリ | 206,096 KB |
最終ジャッジ日時 | 2025-01-18 17:18:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 WA * 14 |
ソースコード
#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=int; 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>; int N,Q,P; vii dp; 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)); if(mem[A[now-1]][val]!=-1) dp[now][val]=std::max(dp[now][val],dfs(now-1,mem[A[now-1]][val])); 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()); cin>>N>>Q>>P; A.resize(N); rep(i,0,N) cin>>A[i]; dp.resize(N+1,vi(P,-1)); mem.resize(P,vi(P,-1)); vi cnt(P); rep(i,0,P){ rep(j,0,P) mem[i][i*j%P]=j; } while(Q--){ ll L,R,K; cin>>L>>R>>K; string ans="No"; if(dfs(R,K)>=L) ans="Yes"; cout<<ans<<endl; } }