結果
| 問題 | No.876 Range Compress Query |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-21 08:10:41 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 158 ms / 2,000 ms |
| + 501µs | |
| コード長 | 798 bytes |
| 記録 | |
| コンパイル時間 | 4,338 ms |
| コンパイル使用メモリ | 361,560 KB |
| 実行使用メモリ | 12,748 KB |
| 最終ジャッジ日時 | 2026-09-21 08:10:52 |
| 合計ジャッジ時間 | 7,558 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
using namespace std;
using namespace atcoder;
using ll = long long;
struct S{ ll l, r, c; };
using F = ll;
S op(S l, S r){ return{ l.l, r.r, l.c+r.c+(l.r != r.l) }; }
S e(){ return{ 0, 0, 0 }; }
S mapp(F f, S x){ x.l += f, x.r += f; return x; }
F comp(F f, F g){ return f+g; }
F id(){ return 0; }
int main(){
int N, Q;
cin >> N >> Q;
lazy_segtree<S, op, e, F, mapp, comp, id> seg(N);
for (int i = 0; i < N; i++){
int x;
cin >> x;
seg.set(i, S{x, x, 0});
}
while (Q--){
int t, l, r, x;
cin >> t >> l >> r, l--;
if (t == 1){
cin >> x;
seg.apply(l, r, x);
}
else{
cout << seg.prod(l, r).c-1 << endl;
}
}
}