void update(int x,int y,ll d){
while(x<=n){
int tmp=y;
while(tmp<=m)
c[x][tmp]+=d,tmp+=tmp&-tmp;
x+=x&-x;
}
}
ll query(int x,int y){
ll res=0;
while(x<=n){
int tmp=y;
while(tmp<=m)
res+=c[x][tmp],tmp-=tmp&-tmp;
x-=x&-x;
}
return res;
}
二维树状数组
最新推荐文章于 2022-10-05 14:53:53 发布