結果

問題 No.2395 区間二次変換一点取得
ユーザー 河城白露河城白露
提出日時 2023-07-28 22:46:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,075 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 84,388 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 06:44:14
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 9 ms
6,944 KB
testcase_13 AC 70 ms
6,940 KB
testcase_14 AC 70 ms
6,944 KB
testcase_15 AC 69 ms
6,784 KB
testcase_16 AC 71 ms
6,912 KB
testcase_17 AC 72 ms
6,784 KB
testcase_18 AC 60 ms
6,912 KB
testcase_19 AC 59 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define ll long long
#define db double
using namespace std;
const ll N = 1e5 + 100;
ll tt,tr[N],n,md,q;
struct answer{
	ll x,y,z;
	void prt() {
		printf("%lld %lld %lld\n",x,y,z);
	}
}ans[N];
ll lwb(ll p) {
	return (p & (-p));
}
void add(ll p,ll k) {
	while(p <= n) {
		tr[p] += k;
		p += lwb(p);
	}
}
ll sum(ll p) {
	ll res = 0;
	while(p > 0) {
		res += tr[p];
		p -= lwb(p);
	}
	return res;
}
void solve() {
	scanf("%lld%lld%lld",&n,&md,&q);
	ans[0].x = ans[0].y = ans[0].z = (1 % md);
	for (ll i = 1;i <= q;i++) {
		ans[i] = ans[i - 1];
		ans[i].x = (ans[i].x + 1) % md;
		ans[i].y = (3 * ans[i].y + ans[i].x * ans[i].z * 2) % md;
		ans[i].z = (3 * ans[i].z) % md;
	}
	memset(tr,0,sizeof(tr));
	for (ll i = 1;i <= q;i++) {
		ll l,m,r;
		scanf("%lld%lld%lld",&l,&m,&r);
		add(l,1);
		add(r + 1,-1);
		ans[sum(m)].prt();
	}
}
int main() {
	tt = 1;
	while(tt) {
		solve();
		tt--;
	}
	return 0;
}
0