@[focus_costan](/user/677604)
pushdown 错了:
```
void pushdown(int x,int l,int r){
int mid=(l+r)>>1;
tree[x<<1].lazy^=1;
tree[x<<1|1].lazy^=1;
tree[x<<1].sum = mid-l+1-tree[x<<1].sum;
tree[x<<1|1].sum = r - mid - tree[x<<1|1].sum;
// tree[x<<1].sum+=tree[x].lazy*(mid-l+1);
// tree[x<<1|1].sum+=tree[x].lazy*(r-mid);
tree[x].lazy=0;
}
```
后面相应的也要改。
不过除了 pushdown,还有别的问题。
by DAhhr76 @ 2024-04-25 22:57:28
@[focus_costan1](/user/1148600) 好了好了改好了,pushdown 前面加上一个特判:
```
void pushdown(int x,int l,int r){
if(tree[x].lazy) {
int mid=(l+r)>>1;
tree[x<<1].lazy^=1;
tree[x<<1|1].lazy^=1;
tree[x<<1].sum = mid-l+1-tree[x<<1].sum;
tree[x<<1|1].sum = r - mid - tree[x<<1|1].sum;
// tree[x<<1].sum+=tree[x].lazy*(mid-l+1);
// tree[x<<1|1].sum+=tree[x].lazy*(r-mid);
tree[x].lazy=0;
}
}
```
by DAhhr76 @ 2024-04-25 22:59:41
thk,@[DAhhr76](/user/1073341)
by s11304 @ 2024-04-26 08:08:52
@[s11304](/user/1012470) 嗯?你们同一个人?
by DAhhr76 @ 2024-04-26 22:08:52
不是,我们是同学 @[DAhhr76](/user/1073341)
by s11304 @ 2024-04-27 08:22:47
@[s11304](/user/1012470) 哦。
by DAhhr76 @ 2024-04-27 20:49:41