結果

問題 No.1349 Subset Product Queries
ユーザー hamrayhamray
提出日時 2021-09-03 23:33:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 1,659 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 170,596 KB
実行使用メモリ 95,936 KB
最終ジャッジ日時 2023-08-22 01:45:24
合計ジャッジ時間 9,323 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 241 ms
93,544 KB
testcase_12 AC 223 ms
83,800 KB
testcase_13 AC 222 ms
83,584 KB
testcase_14 AC 228 ms
87,424 KB
testcase_15 AC 234 ms
88,772 KB
testcase_16 AC 241 ms
94,292 KB
testcase_17 AC 180 ms
60,536 KB
testcase_18 AC 71 ms
9,276 KB
testcase_19 AC 63 ms
6,372 KB
testcase_20 AC 204 ms
73,716 KB
testcase_21 AC 228 ms
84,900 KB
testcase_22 AC 180 ms
59,208 KB
testcase_23 AC 213 ms
79,244 KB
testcase_24 AC 159 ms
49,212 KB
testcase_25 AC 198 ms
69,796 KB
testcase_26 AC 245 ms
95,936 KB
testcase_27 AC 182 ms
61,292 KB
testcase_28 AC 183 ms
61,352 KB
testcase_29 AC 180 ms
59,980 KB
testcase_30 AC 186 ms
63,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
 
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
 
#define MOD 1000000007
 
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
const double EPS = 1e-8, PI = acos(-1);
const double pi = 3.141592653589793238462643383279;
//ここから編集    

int main() {  
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int n, q, p; cin >> n >> q >> p;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  vector<vector<int>> dp(n+1, vector<int>(p, -1));
  for(int i=0; i<n; i++) {
    for(int j=0; j<p; j++) {
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      dp[i+1][(j*a[i])%p] = max(dp[i+1][(j*a[i])%p], dp[i][j]);
    }
    dp[i+1][a[i]] = i;
  }

  REP(i,q) {
    int l, r, k; cin >> l >> r >> k;
    
    if(dp[r][k] >= l-1) {
      cout << "Yes" << '\n';
    }else{
      cout << "No" << '\n';
    }
  }
  return 0;
}
0