結果

問題 No.2395 区間二次変換一点取得
ユーザー kwm_tkwm_t
提出日時 2023-07-28 22:01:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,437 bytes
コンパイル時間 2,414 ms
コンパイル使用メモリ 200,056 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2024-04-16 05:57:14
合計ジャッジ時間 4,800 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 10 ms
6,944 KB
testcase_13 AC 102 ms
7,680 KB
testcase_14 AC 102 ms
7,680 KB
testcase_15 AC 100 ms
7,552 KB
testcase_16 AC 101 ms
7,680 KB
testcase_17 AC 101 ms
7,680 KB
testcase_18 AC 68 ms
7,680 KB
testcase_19 AC 68 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
template<class S, S op(S l, S r), S e()>
struct DualSegtree {
private:
	int mn = 0;
	int mN = 0;
	int mlogN = 0;
	std::vector<S> A;
	void propagate(int i) {
		if (i >= mN) return;
		A[i * 2] = op(A[i * 2], A[i]);
		A[i * 2 + 1] = op(A[i * 2 + 1], A[i]);
		A[i] = e();
	}
	void full_propagate(int i) {
		for (int d = mlogN; d > 0; d--) propagate(i >> d);
	}
public:
	DualSegtree(int n = 0) {
		mn = n;
		mlogN = 0; mN = 1;
		while (mN < n) { mN *= 2; mlogN++; }
		A.assign(mN * 2, e());
	}
	void point_init(int p) {
		assert(0 <= p); assert(p < mn);
		p += mN;
		full_propagate(p);
		A[p] = e();
	}
	S get(int p) {
		assert(0 <= p); assert(p < mn);
		p += mN;
		full_propagate(p);
		return A[p];
	}
	void apply(int l, int r, S x) {
		l += mN;
		r += mN;
		if (l != mN) full_propagate(l - 1);
		if (r != mN * 2) full_propagate(r);
		while (l < r) {
			if (l & 1) { A[l] = op(A[l], x); l++; }
			if (r & 1) { r--; A[r] = op(A[r], x); }
			l /= 2; r /= 2;
		}
	}
};
//区間加算、一点取得
using S = long long;
S op(S x, S f) { return { x + f }; }
S e() { return { 0 }; }
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, b, q; cin >> n >> b >> q;
	DualSegtree<S, op, e>seg(n);
	vector<long long>x(n + 1), y(n + 1), z(n + 1);
	x[0] = 1, y[0] = 1, z[0] = 1;
	rep(i, n) {
		x[i + 1] = (x[i] + 1) % b;;
		y[i + 1] = (3LL * y[i] + 2LL * x[i + 1] * z[i]) % b;
		z[i + 1] = (3LL * z[i]) % b;
	}
	rep(i, q) {
		int l, m, r; cin >> l >> m >> r;
		l--, m--, r--;
		seg.apply(l, r + 1, 1);
		auto val = seg.get(m);
		cout << x[val] << " " << y[val] << " " << z[val] << endl;
	}
	return 0;
}
0