結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー QCFiumQCFium
提出日時 2020-05-29 22:43:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 1,291 bytes
コンパイル時間 1,658 ms
コンパイル使用メモリ 171,404 KB
実行使用メモリ 113,536 KB
最終ジャッジ日時 2024-04-24 00:10:07
合計ジャッジ時間 3,596 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 96 ms
75,520 KB
testcase_12 AC 69 ms
49,152 KB
testcase_13 AC 119 ms
101,504 KB
testcase_14 AC 65 ms
60,800 KB
testcase_15 AC 30 ms
28,032 KB
testcase_16 AC 29 ms
22,656 KB
testcase_17 AC 6 ms
7,808 KB
testcase_18 AC 73 ms
62,720 KB
testcase_19 AC 72 ms
66,176 KB
testcase_20 AC 45 ms
29,568 KB
testcase_21 AC 161 ms
113,536 KB
testcase_22 AC 161 ms
113,536 KB
testcase_23 AC 162 ms
113,536 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rs64() {
	int64_t n;
	scanf("%" SCNd64, &n);
	return n;
}

#define MOD 998244353
int main() {
	int n = ri(), q = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::sort(a, a + n);
	
	int mult[n + 1];
	mult[0] = 1;
	for (int i = 0; i < n; i++) mult[i + 1] = (int64_t) mult[i] * a[i] % MOD;
	
	std::vector<int> poly[n + 1];
	poly[n] = { 1 };
	for (int i = n; i--; ) {
		poly[i] = poly[i + 1];
		poly[i].insert(poly[i].begin(), 0);
		for (int j = 1; j < (int) poly[i].size(); j++) poly[i][j - 1] = (poly[i][j - 1] + (int64_t) poly[i][j] * (a[i] - 1)) % MOD;
	}
	
	std::pair<int, int> ranges[n + 1];
	for (int i = 0; i < n; i++) ranges[i].second = ranges[i + 1].first = a[i] + 1;
	ranges[0].first = 1;
	ranges[n].second = 1000000001;
	
	for (int i = 0; i < q; i++) {
		int l = ri();
		int r = ri() + 1;
		int p = ri();
		int res = 0;
		for (int j = 0; j <= n; j++) {
			std::pair<int, int> range = {std::max(ranges[j].first, l), std::min(ranges[j].second, r)};
			if (range.second <= range.first) continue;
			if (!((range.second - range.first) & 1)) continue;
			if (p >= (int) poly[j].size()) continue;
			res ^= (int64_t) mult[j] * poly[j][p] % MOD;
		}
		res %= MOD;
		printf("%d\n", res);
	}
	return 0;
}
0