結果

問題 No.1349 Subset Product Queries
ユーザー rabimearabimea
提出日時 2023-03-01 18:47:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 433 ms / 2,000 ms
コード長 1,137 bytes
コンパイル時間 2,484 ms
コンパイル使用メモリ 203,248 KB
実行使用メモリ 107,588 KB
最終ジャッジ日時 2023-10-14 22:41:37
合計ジャッジ時間 11,674 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 428 ms
100,292 KB
testcase_12 AC 389 ms
89,912 KB
testcase_13 AC 391 ms
90,204 KB
testcase_14 AC 385 ms
101,996 KB
testcase_15 AC 419 ms
95,520 KB
testcase_16 AC 433 ms
101,044 KB
testcase_17 AC 303 ms
82,876 KB
testcase_18 AC 119 ms
33,160 KB
testcase_19 AC 107 ms
30,236 KB
testcase_20 AC 374 ms
99,392 KB
testcase_21 AC 351 ms
107,504 KB
testcase_22 AC 277 ms
85,668 KB
testcase_23 AC 350 ms
105,140 KB
testcase_24 AC 256 ms
75,360 KB
testcase_25 AC 306 ms
95,764 KB
testcase_26 AC 358 ms
107,588 KB
testcase_27 AC 285 ms
88,004 KB
testcase_28 AC 278 ms
87,272 KB
testcase_29 AC 288 ms
86,504 KB
testcase_30 AC 296 ms
89,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
using vi = vector <int>;
using ll = long long;
using vl = vector <ll>;
using pii = pair <int, int>;
const ll mod = 998244353;
//~ const ll mod = 1e9 + 7;
ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a;
	for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; }

const int N = 5e3 + 11;
int f[N][N];
int a[N];

void chmax(int &a, int b) {
	if(a < b) a = b;
}

struct Query {
	int l, r, k;
	int id;
};
vector <Query> qs[N];

const int M = 2e5 + 11;
int ans[M];

int main() {
	ios::sync_with_stdio(0);
	int n, q, p; cin >> n >> q >> p;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	
	for(int i = 1; i <= q; i ++) {
		int l, r, k;
		cin >> l >> r >> k;
		qs[r].pb({l, r, k, i});
	}
	
	for(int i = 1; i <= n; i ++) {
		for(int j = 0; j < p; j ++) {
			chmax(f[i][j], f[i - 1][j]);
			chmax(f[i][j * a[i] % p], f[i - 1][j]);
		}
		f[i][a[i]] = i;
		for(Query q : qs[i])
			if(f[i][q.k] >= q.l)
				ans[q.id] = 1;
			else
				ans[q.id] = 0;
	}
	
	for(int i = 1; i <= q; i ++)
		cout << (ans[i] ? "Yes" : "No") << '\n';
}

0