跳到正文

个人记录

25.10.3 标记永久化矩形面积并

Cipher0128约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月27日
篇幅
约 1 分钟

版本

  1. v1当前

没有 pushdownpushdown,在 pushuppushup 的过程中看有没有被整段覆盖。

C++
void pup(int p,int l,int r){
	if(t[p].sum)t[p].len=r-l+1;
	else t[p].len=t[lc].len+t[rc].len;
}
void build(int p,int l,int r){
	t[p]={0,0};
	if(l==r)return;
	build(lc,l,md);build(rc,md+1,r);pup(p,l,r);
}
void mdf(int p,int l,int r,int x,int y,int v){
	if(x<=l&&r<=y)return t[p].sum+=v,pup(p,l,r);
	if(x<=md)mdf(lc,l,md,x,y,v);
	if(y>=md+1)mdf(rc,md+1,r,x,y,v);
	pup(p,l,r);
}
原文