結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー QCFiumQCFium
提出日時 2020-05-29 22:33:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,255 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 169,772 KB
実行使用メモリ 113,536 KB
最終ジャッジ日時 2024-04-23 23:36:39
合計ジャッジ時間 3,905 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 157 ms
113,536 KB
testcase_22 AC 156 ms
113,536 KB
testcase_23 AC 159 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();
	
	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;
		}
		printf("%d\n", res);
	}
	return 0;
}
0