0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 14:16:28 +00:00

#134. 二维树状数组 2:区间修改,单点查询

https://loj.ac/s/1687117
This commit is contained in:
Baoshuo Ren 2023-01-30 11:13:24 +08:00
parent f82b0b1a62
commit 828a598332
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
43 changed files with 192 additions and 0 deletions

66
LibreOJ/134/134.cpp Normal file
View File

@ -0,0 +1,66 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = (1 << 12) + 5;
int n, m, op;
long long c[N][N];
int lowbit(int x) {
return x & -x;
}
void add(int x, int y, int v) {
for (int i = x; i <= n; i += lowbit(i)) {
for (int j = y; j <= m; j += lowbit(j)) {
c[i][j] += v;
}
}
}
void add(int x1, int y1, int x2, int y2, int v) {
add(x1, y1, v);
add(x1, y2 + 1, -v);
add(x2 + 1, y1, -v);
add(x2 + 1, y2 + 1, v);
}
long long sum(int x, int y) {
long long res = 0;
for (int i = x; i; i -= lowbit(i)) {
for (int j = y; j; j -= lowbit(j)) {
res += c[i][j];
}
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
while (cin >> op) {
if (op == 1) {
int a, b, c, d, k;
cin >> a >> b >> c >> d >> k;
add(a, b, c, d, k);
} else { // op == 2
int x, y;
cin >> x >> y;
cout << sum(x, y) << endl;
}
}
return 0;
}

BIN
LibreOJ/134/data/0.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/0.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/134/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.