yuanshuu @ 2024-08-15 18:36:35
1.第十个tle的话用scanf printf
2.结果可能爆int 改用long long
3.如果用lzy1表示第一种修改 lzy2表示第二种修改
lzy1得初始化为-1e17 lzy2初始化为0
下移操作要先处理1,再2.
处理完lzy1后lzy1恢复成 -1e17
处理完lzy2后lzy2恢复成 0
void push_down(int i){
if(tree[i].lzy1!=minn){
tree[lc].lzy1=tree[i].lzy1;
tree[rc].lzy1=tree[i].lzy1;
tree[lc].num=tree[i].lzy1;
tree[rc].num=tree[i].lzy1;
tree[lc].lzy2=0;
tree[rc].lzy2=0;
tree[i].lzy1=minn;
}
if(tree[i].lzy2){
tree[lc].lzy2+=tree[i].lzy2;
tree[rc].lzy2+=tree[i].lzy2;
tree[lc].num+=tree[i].lzy2;
tree[rc].num+=tree[i].lzy2;
tree[i].lzy2=0;
}
return ;
}
4.各种小细节 修改一:
if(tree[i].l>=x&&tree[i].r<=y){
tree[i].lzy1=k;
tree[i].lzy2=0;
tree[i].num=k;
return tree[i].num;
}
修改二:
if(tree[i].l>=x&&tree[i].r<=y){
tree[i].lzy2+=k;
tree[i].num+=k;
return tree[i].num;
}
by Thomas_mum @ 2024-08-19 17:27:00
感谢
by Will_qwq @ 2024-08-20 17:03:45
谢谢楼主(大声)