```cpp
void add(int p, int l, int r, int v) {
if (l <= tree[p].l && r >= tree[p].r) {
//pushdown1(p);
tree[p].tag2 += v;
tree[p].rmx += v;
return;
}
pushdown1(p), pushdown2(p);
int mid = (tree[p].l + tree[p].r) >> 1;
if (l <= mid) add(lson, l, r, v);
if (r > mid) add(rson, l, r, v);
pushup(p);
}
```
不太懂这里为什么要 pushdown,删掉就对了。
by Failure_Creator @ 2023-09-30 22:16:01
@[Unino](/user/706290)
by Failure_Creator @ 2023-09-30 22:16:18
@[haimo_qwq](/user/486677) thx%%%,这里更新时可能是叶子节点,没有 $\tt lson$ 和 $\tt rson$,所以会 RE
by Unino @ 2023-10-01 07:07:38
```cpp
void pushdown1(int p) {
if (tree[p].tag1 != INF && lson < (n << 2) && rson < (n << 2)) {
tree[lson].rmx = tree[rson].rmx = tree[p].tag1;
tree[lson].tag1 = tree[rson].tag1 = tree[p].tag1;
tree[lson].tag2 = tree[rson].tag2 = 0;
tree[p].tag1 = INF;
}
}
````
by Unino @ 2023-10-01 07:25:04