結果

問題 No.876 Range Compress Query
ユーザー tailstails
提出日時 2021-03-23 20:09:40
言語 cLay
(20240104-1)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 364 bytes
コンパイル時間 2,619 ms
コンパイル使用メモリ 174,656 KB
実行使用メモリ 5,176 KB
最終ジャッジ日時 2023-09-19 02:18:33
合計ジャッジ時間 4,923 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 14 ms
5,084 KB
testcase_12 AC 12 ms
4,992 KB
testcase_13 AC 12 ms
4,776 KB
testcase_14 AC 14 ms
4,832 KB
testcase_15 AC 11 ms
4,864 KB
testcase_16 AC 14 ms
5,176 KB
testcase_17 AC 14 ms
5,104 KB
testcase_18 AC 15 ms
5,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

{
	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