結果
| 問題 |
No.1349 Subset Product Queries
|
| コンテスト | |
| ユーザー |
penguinman
|
| 提出日時 | 2021-02-11 06:20:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,532 bytes |
| コンパイル時間 | 2,376 ms |
| コンパイル使用メモリ | 210,228 KB |
| 最終ジャッジ日時 | 2025-01-18 17:17:41 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 1 |
| other | AC * 13 TLE * 8 MLE * 9 |
ソースコード
#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));
for(auto p:mem[A[now-1]*P+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());
cin>>N>>Q>>P;
A.resize(N);
rep(i,0,N) cin>>A[i];
dp.resize(N+1,vi(P,-1));
mem.resize(P*P);
vi cnt(P);
rep(i,0,P){
rep(j,0,P) mem[i*P+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;
}
}
penguinman