RT,线段树莫名 re
删掉除了 build 和 pushup 的所有函数后还是 re。删掉 pushup 后变成 wa,奇怪捏
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct node{
int l,r,w,lazy,siz;
}tree[2][N*8];
int pushup(int x,int k){
tree[k][x].w=tree[k][x*2].w+tree[k][x*2+1].w;
}
void pushdown(int x,int k){
int tag=tree[k][x].lazy;
if(tree[k][x].lazy==0) return;
tree[k][x*2].lazy+=tag;
tree[k][x*2+1].lazy+=tag;
tree[k][x*2].w+=tree[k][x*2].siz*tag;
tree[k][x*2+1].w+=tree[k][x*2+1].siz*tag;
tree[k][x].lazy=0;
}
void build(int x,int l,int r,int k){
tree[k][x].l=l; tree[k][x].r=r;
tree[k][x].siz=r-l+1; tree[k][x].lazy=0;
if(l==r){
tree[k][x].w=0;
return;
}
int mid=(l+r)/2;
build(x*2,l,mid,k); build(x*2+1,mid+1,r,k);
//pushup(x,k);
}
void modify(int x,int l,int r,int val,int k){
if(l>r) return;
if(tree[k][x].l>=l&&tree[k][x].r<=r){
tree[k][x].w+=tree[k][x].siz*val;
tree[k][x].lazy+=val; return;
}
if(tree[k][x].l>r||tree[k][x].r<l) return;
pushdown(x,k);
modify(x*2,l,r,val,k); modify(x*2+1,l,r,val,k);
pushup(x,k);
}
int query(int x,int pos,int k){
if(tree[k][x].r<pos||tree[k][x].l>pos) return 0;
if(tree[k][x].l==tree[k][x].r) return tree[k][x].w;
pushdown(x,k);
return query(x*2,pos,k)+query(x*2+1,pos,k);
}
inline void fake_main(){
int n,m; cin>>n>>m;
build(1,1,n,0); build(1,1,n,1); int tot=0;
for(int i=1;i<=m;i++){
int q,l,r; cin>>q>>l>>r;
if(q==1){
// modify(1,1,l-1,1,0);
// modify(1,r+1,n,1,1);
// tot++;
}else if(q==2){
// cout<<tot-query(1,r,0)-query(1,l,1)<<"\n";
}
}
}
signed main(){
ios::sync_with_stdio(false);
int t; t=1;
while(t--) fake_main();
}