結果

問題 No.876 Range Compress Query
コンテスト
ユーザー 👑 tails
提出日時 2021-03-23 20:09:40
言語 cLay
(20250308-1 + boost 1.89.0)
コンパイル:
clayc _filename_
実行:
./a.out
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 364 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,201 ms
コンパイル使用メモリ 195,280 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-26 23:54:28
合計ジャッジ時間 3,811 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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