結果

問題 No.1673 Lamps on a line
ユーザー tailstails
提出日時 2021-09-10 21:56:34
言語 cLay
(20240104-1)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 361 bytes
コンパイル時間 2,650 ms
コンパイル使用メモリ 173,664 KB
実行使用メモリ 16,736 KB
最終ジャッジ日時 2023-09-19 02:39:36
合計ジャッジ時間 4,933 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 5 ms
4,384 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 8 ms
4,380 KB
testcase_07 AC 42 ms
15,016 KB
testcase_08 AC 9 ms
12,752 KB
testcase_09 AC 36 ms
7,984 KB
testcase_10 AC 49 ms
11,012 KB
testcase_11 AC 9 ms
9,652 KB
testcase_12 AC 30 ms
16,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

struct S{
	int f,x,y;
};

inline
S segtree_ph_func(S a,S b){
	return {a.f^b.f,(b.f?a.y:a.x)+b.x,(b.f?a.x:a.y)+b.y};
}

{
	segtree_ph<S>t;
	ll@n,@q;
	t.walloc(n+2,1);
	rep(i,n+2){
		t[i]={0,0,1};
	}
	t.build();
	rep(q){
		ll@l,@r;
		{
			S s=t[l-1];
			s.f^=1;
			t.change(l-1,s);
		}
		{
			S s=t[r];
			s.f^=1;
			t.change(r,s);
		}
		wt(t.get(0,n+2).x);
	}
}
0