mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 19:48:51 +00:00
parent
b44484d52c
commit
f82b0b1a62
63
LibreOJ/133/133.cpp
Normal file
63
LibreOJ/133/133.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
long long sum(int x1, int y1, int x2, int y2) {
|
||||
return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m;
|
||||
|
||||
while (cin >> op) {
|
||||
if (op == 1) {
|
||||
int x, y, k;
|
||||
|
||||
cin >> x >> y >> k;
|
||||
|
||||
add(x, y, k);
|
||||
} else { // op == 2
|
||||
int a, b, c, d;
|
||||
|
||||
cin >> a >> b >> c >> d;
|
||||
|
||||
cout << sum(a, b, c, d) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
LibreOJ/133/data/1.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/1.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/10.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/10.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/11.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/11.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/2.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/2.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/3.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/3.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/4.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/4.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/5.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/5.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/6.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/6.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/7.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/7.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/8.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/8.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/9.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/133/data/9.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/133/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user