void add(int x, int y, int d) {
int i, j;
for(i = x; i < N; i += lowbit(i))
for(j = y; j < N; j += lowbit(j))
mat[i][j] += d;
}
LL sum(int x, int y) {
LL res = 0;
int i, j;
for(i = x; i > 0; i -= lowbit(i))
for(j = y; j > 0; j -= lowbit(j))
res += mat[i][j];
return res;
}
二维树状数组模板
最新推荐文章于 2020-07-28 22:13:21 发布