結果

問題 No.876 Range Compress Query
ユーザー tailstails
提出日時 2021-03-23 19:49:27
言語 cLay
(20240104-1)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 2,429 ms
コンパイル使用メモリ 170,996 KB
実行使用メモリ 8,112 KB
最終ジャッジ日時 2023-09-19 02:18:37
合計ジャッジ時間 3,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,324 KB
testcase_01 AC 2 ms
5,344 KB
testcase_02 AC 2 ms
5,328 KB
testcase_03 AC 2 ms
5,404 KB
testcase_04 AC 2 ms
5,296 KB
testcase_05 AC 2 ms
5,632 KB
testcase_06 AC 2 ms
5,512 KB
testcase_07 AC 2 ms
5,308 KB
testcase_08 AC 2 ms
5,344 KB
testcase_09 AC 2 ms
5,348 KB
testcase_10 AC 2 ms
5,344 KB
testcase_11 AC 19 ms
7,880 KB
testcase_12 AC 16 ms
7,832 KB
testcase_13 AC 16 ms
7,724 KB
testcase_14 AC 19 ms
7,804 KB
testcase_15 AC 15 ms
7,896 KB
testcase_16 AC 19 ms
8,088 KB
testcase_17 AC 18 ms
8,112 KB
testcase_18 AC 20 ms
8,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fenwick<ll>f;
ll n,q,a[1d5],t[];
ll b,l,r,x;

{
	rd(n,q,a(n));
	f.walloc(n,1);
	rep(i,n-1)f.add(i,t[i]=(a[i]=a[i+1]-a[i])!=0);
	rep(q){
		rd(b,l,r);
		--l; --r;
		if(b==1){
			rd(x);
			if(--l>=0) f.add(l,((a[l]+=x)!=0)-t[l]),t[l]=a[l]!=0;
			f.add(r,((a[r]-=x)!=0)-t[r]),t[r]=a[r]!=0;
		}else{
			wt(1ll+(l==r?0:f.range(l,r-1)));
		}
	}
}
0