結果

問題 No.2395 区間二次変換一点取得
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-07-29 00:41:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 2,216 ms
コンパイル使用メモリ 194,300 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-16 08:32:23
合計ジャッジ時間 5,117 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int bbb[200020];
int si;
void init(int N) {
	si = N;
	fill(bbb, bbb + (N + 1), 0);
}
void add(int id, int a) {
	id ++;
	while (id <= si) {
		bbb[id] += a;
		id += (id & (-id));
	}
}
int sum(int id) {
	int ret = 0;
	while (id) {
		ret += bbb[id];
		id -= (id & (-id));
	}
	return ret;
}
int main() {
	int N, Q; ll B;
	cin >> N >> B >> Q;
	init(N);
	ll X[200020], Y[200020], Z[200020];
	X[0] = Y[0] = Z[0] = 1;
	for (int i = 1; i <= Q; i ++) {
		X[i + 1] = (X[i] + 1) % B;
		Y[i + 1] = (3 * Y[i] + X[i + 1] * Z[i]) % B;
		Z[i + 1] = (3 * Z[i]) % B;
	}
	while (Q--) {
		int l, m, r;
		cin >> l >> m >> r;
		add(--l, 1); add(r, -1);
		int x = sum(m);
		printf("%lld %lld %lld\n", X[x], Y[x], Z[x]);
	}
}
0