31pts 求调

P3038 [USACO11DEC] Grass Planting G

``` void maketag(int id) { a[id].laz = 1; a[id].sum += (a[id].r - a[id].l + 1); } ``` 应该改为 ``` void maketag(int id) { a[id].laz += 1; a[id].sum += (a[id].r - a[id].l + 1); } ``` 因为懒标记可能被更新不止一次 ------------ 附hack数据 in ``` 6 3 1 2 1 3 3 4 4 5 5 6 P 3 6 P 3 6 Q 5 6 ``` out ``` 2 ```
by MAZHIYUAN @ 2023-11-16 16:31:02


还有pushdown不能共用maketag函数,应改为 ``` void pushdown(int id) { if(!a[id].laz) return; a[lc].sum += (a[lc].r - a[lc].l + 1) * a[id].laz; a[rc].sum += (a[rc].r - a[rc].l + 1) * a[id].laz; a[lc].laz += a[id].laz; a[rc].laz += a[id].laz; a[id].laz = 0; } ``` 改完就过了
by MAZHIYUAN @ 2023-11-16 17:00:50


|