結果

問題 No.230 Splarraay スプラレェーイ
ユーザー yuruhiyayuruhiya
提出日時 2021-04-12 20:44:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 180 ms / 5,000 ms
コード長 642 bytes
コンパイル時間 3,783 ms
コンパイル使用メモリ 147,140 KB
実行使用メモリ 13,400 KB
最終ジャッジ日時 2023-09-11 02:03:25
合計ジャッジ時間 6,155 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 10 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 81 ms
8,208 KB
testcase_10 AC 82 ms
4,380 KB
testcase_11 AC 46 ms
5,648 KB
testcase_12 AC 82 ms
8,124 KB
testcase_13 AC 13 ms
4,376 KB
testcase_14 AC 88 ms
13,328 KB
testcase_15 AC 126 ms
13,256 KB
testcase_16 AC 151 ms
13,228 KB
testcase_17 AC 180 ms
13,400 KB
testcase_18 AC 119 ms
13,384 KB
testcase_19 AC 105 ms
13,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using namespace std;
using ll = long long;

struct S { ll v,s; };
S op(S a,S b) { return {a.v+b.v,a.s+b.s}; }
S e() { return {0,0}; }
S ma(ll f,S x) { return {f<0?x.v:f*x.s,x.s}; }
ll co(ll f,ll g) { return f==-1?g:f; }
ll id() { return -1; }

int main() {
	int n,q;
	cin>>n>>q;
	atcoder::lazy_segtree<S,op,e,ll,ma,co,id> A(vector(n,S{0,1}));
	auto B=A;
	ll a=0,b=0;
	for (; q--;) {
		int x,l,r;
		cin>>x>>l>>r,r++;
		if (x) {
			A.apply(l,r,!~-x);
			B.apply(l,r,+~-x);
		} else {
			ll x=A.prod(l,r).v,y=B.prod(l,r).v;
			if (x>y) a+=x;
			if (x<y) b+=y;
		}
	}
	cout<<a+A.all_prod().v<<' '<<b+B.all_prod().v<<'\n';
}
0