From f82b0b1a62cb6e3df02b71578b95deeba79b8efc Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 30 Jan 2023 10:52:59 +0800 Subject: [PATCH] =?UTF-8?q?#133.=20=E4=BA=8C=E7=BB=B4=E6=A0=91=E7=8A=B6?= =?UTF-8?q?=E6=95=B0=E7=BB=84=201=EF=BC=9A=E5=8D=95=E7=82=B9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E5=8C=BA=E9=97=B4=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1687063 --- LibreOJ/133/133.cpp | 63 +++++++++++++++++++++++++++++++++++++++++ LibreOJ/133/data/1.in | 3 ++ LibreOJ/133/data/1.out | 3 ++ LibreOJ/133/data/10.in | 3 ++ LibreOJ/133/data/10.out | 3 ++ LibreOJ/133/data/11.in | 3 ++ LibreOJ/133/data/11.out | 3 ++ LibreOJ/133/data/2.in | 3 ++ LibreOJ/133/data/2.out | 3 ++ LibreOJ/133/data/3.in | 3 ++ LibreOJ/133/data/3.out | 3 ++ LibreOJ/133/data/4.in | 3 ++ LibreOJ/133/data/4.out | 3 ++ LibreOJ/133/data/5.in | 3 ++ LibreOJ/133/data/5.out | 3 ++ LibreOJ/133/data/6.in | 3 ++ LibreOJ/133/data/6.out | 3 ++ LibreOJ/133/data/7.in | 3 ++ LibreOJ/133/data/7.out | 3 ++ LibreOJ/133/data/8.in | 3 ++ LibreOJ/133/data/8.out | 3 ++ LibreOJ/133/data/9.in | 3 ++ LibreOJ/133/data/9.out | 3 ++ 23 files changed, 129 insertions(+) create mode 100644 LibreOJ/133/133.cpp create mode 100644 LibreOJ/133/data/1.in create mode 100644 LibreOJ/133/data/1.out create mode 100644 LibreOJ/133/data/10.in create mode 100644 LibreOJ/133/data/10.out create mode 100644 LibreOJ/133/data/11.in create mode 100644 LibreOJ/133/data/11.out create mode 100644 LibreOJ/133/data/2.in create mode 100644 LibreOJ/133/data/2.out create mode 100644 LibreOJ/133/data/3.in create mode 100644 LibreOJ/133/data/3.out create mode 100644 LibreOJ/133/data/4.in create mode 100644 LibreOJ/133/data/4.out create mode 100644 LibreOJ/133/data/5.in create mode 100644 LibreOJ/133/data/5.out create mode 100644 LibreOJ/133/data/6.in create mode 100644 LibreOJ/133/data/6.out create mode 100644 LibreOJ/133/data/7.in create mode 100644 LibreOJ/133/data/7.out create mode 100644 LibreOJ/133/data/8.in create mode 100644 LibreOJ/133/data/8.out create mode 100644 LibreOJ/133/data/9.in create mode 100644 LibreOJ/133/data/9.out diff --git a/LibreOJ/133/133.cpp b/LibreOJ/133/133.cpp new file mode 100644 index 00000000..8c1ad64a --- /dev/null +++ b/LibreOJ/133/133.cpp @@ -0,0 +1,63 @@ +#include + +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; +} diff --git a/LibreOJ/133/data/1.in b/LibreOJ/133/data/1.in new file mode 100644 index 00000000..91a1307d --- /dev/null +++ b/LibreOJ/133/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eff4ec69255382187cb8c6a7c04ee8c635fead7583851f7973d8e7dd9b2dbed7 +size 4621642 diff --git a/LibreOJ/133/data/1.out b/LibreOJ/133/data/1.out new file mode 100644 index 00000000..5de89703 --- /dev/null +++ b/LibreOJ/133/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35a05d6b598c5c9ffc71252475539c81d81c93e9b35d8c4445ab13b783e8f0ef +size 1258495 diff --git a/LibreOJ/133/data/10.in b/LibreOJ/133/data/10.in new file mode 100644 index 00000000..e80628b8 --- /dev/null +++ b/LibreOJ/133/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b159ba4fccc8899a05ba411fc4e6a02a21ca475c3c815e7851b1e69cac7936ba +size 5888034 diff --git a/LibreOJ/133/data/10.out b/LibreOJ/133/data/10.out new file mode 100644 index 00000000..30cbaaee --- /dev/null +++ b/LibreOJ/133/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6777b224158affbb0f6a2a012ecf51d7ddafc7e885795d4f53b35c9f5b25471 +size 1216163 diff --git a/LibreOJ/133/data/11.in b/LibreOJ/133/data/11.in new file mode 100644 index 00000000..7e8ad8e5 --- /dev/null +++ b/LibreOJ/133/data/11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f11592a47003199476de4f090c765d620841fa2ce1e1cce78e93f61a57fb39e +size 4981235 diff --git a/LibreOJ/133/data/11.out b/LibreOJ/133/data/11.out new file mode 100644 index 00000000..3c1c13d6 --- /dev/null +++ b/LibreOJ/133/data/11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9f246000e1b21161dce2d4b3ec95e57c55cee6a680bf167a54bf70964f4dab3 +size 12 diff --git a/LibreOJ/133/data/2.in b/LibreOJ/133/data/2.in new file mode 100644 index 00000000..a725e5c2 --- /dev/null +++ b/LibreOJ/133/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24df502df560081245bdf3f1bd083dd7906b1e3e111ce646d07469616564ad6a +size 4622165 diff --git a/LibreOJ/133/data/2.out b/LibreOJ/133/data/2.out new file mode 100644 index 00000000..c9ee7abe --- /dev/null +++ b/LibreOJ/133/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cad786007f5c358eb00342c2c583bfe11d8923fa18aee1aedeb759187a76d3f2 +size 1278911 diff --git a/LibreOJ/133/data/3.in b/LibreOJ/133/data/3.in new file mode 100644 index 00000000..3b951258 --- /dev/null +++ b/LibreOJ/133/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51a7fec2d1b24ff498074ebe04ec1d4ad8d89af7fdd0f1378af9b64fcb5c2d33 +size 5886920 diff --git a/LibreOJ/133/data/3.out b/LibreOJ/133/data/3.out new file mode 100644 index 00000000..c4addec5 --- /dev/null +++ b/LibreOJ/133/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8e428bab1a8a8ff48188998bf0a83ff8b53017043a614661aad4dde65e3c2b4 +size 1199731 diff --git a/LibreOJ/133/data/4.in b/LibreOJ/133/data/4.in new file mode 100644 index 00000000..af25b32a --- /dev/null +++ b/LibreOJ/133/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2079279d46f2912de2b9f6e6bb7536c451b41aeb7d8f52a3833c1a5659160e6c +size 5885110 diff --git a/LibreOJ/133/data/4.out b/LibreOJ/133/data/4.out new file mode 100644 index 00000000..5f555072 --- /dev/null +++ b/LibreOJ/133/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98ca09976e107181bd9943b011edb52bb0d907b246ca95a522ba3423d69f26e0 +size 1181456 diff --git a/LibreOJ/133/data/5.in b/LibreOJ/133/data/5.in new file mode 100644 index 00000000..04231ced --- /dev/null +++ b/LibreOJ/133/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96fb6153d3e91836c29a439bd8419a6bfb049334dd6937f805cf7d9aa9603e9e +size 5886212 diff --git a/LibreOJ/133/data/5.out b/LibreOJ/133/data/5.out new file mode 100644 index 00000000..3767eb78 --- /dev/null +++ b/LibreOJ/133/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd8f6187f1639a41c636d9fa3f9556a3c22571922f47b8cb6a10639cb7303c70 +size 1175506 diff --git a/LibreOJ/133/data/6.in b/LibreOJ/133/data/6.in new file mode 100644 index 00000000..5c1381d1 --- /dev/null +++ b/LibreOJ/133/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d23f4d3df65fde06c3944ce3bc94e04c521af898a4b8782690c751a9480de31 +size 5887423 diff --git a/LibreOJ/133/data/6.out b/LibreOJ/133/data/6.out new file mode 100644 index 00000000..1562cfc6 --- /dev/null +++ b/LibreOJ/133/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6019886c1d429c65ecacdb3483b594c30ea1a14ae3f9aa43633b895731378b2 +size 1197895 diff --git a/LibreOJ/133/data/7.in b/LibreOJ/133/data/7.in new file mode 100644 index 00000000..8a555d1a --- /dev/null +++ b/LibreOJ/133/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0fd43822b01983cb8259b54d07c217d9693aa2bcaa2539c7210abb3eb5b9fac9 +size 5884328 diff --git a/LibreOJ/133/data/7.out b/LibreOJ/133/data/7.out new file mode 100644 index 00000000..3406822b --- /dev/null +++ b/LibreOJ/133/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d8c5686f81e60befd0c07563d29ab8d01f130727e27270b8ee80e137ed4d0a3 +size 1181569 diff --git a/LibreOJ/133/data/8.in b/LibreOJ/133/data/8.in new file mode 100644 index 00000000..75fd75ce --- /dev/null +++ b/LibreOJ/133/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5158ac25d1e02b2d82287a6e1fa7dfc7b360a4daa9e436b4f9764247e37cf97e +size 5886870 diff --git a/LibreOJ/133/data/8.out b/LibreOJ/133/data/8.out new file mode 100644 index 00000000..803bb6d1 --- /dev/null +++ b/LibreOJ/133/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfb3394de6bb3eb9619b3e8178132399aa5fb51aeccef4c443c6def0437010d1 +size 1213783 diff --git a/LibreOJ/133/data/9.in b/LibreOJ/133/data/9.in new file mode 100644 index 00000000..e63fc09c --- /dev/null +++ b/LibreOJ/133/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:679487bd66eed10058e6dc2f29e5820be56f0933f453143c8a541fa1d0d22670 +size 5886503 diff --git a/LibreOJ/133/data/9.out b/LibreOJ/133/data/9.out new file mode 100644 index 00000000..8e82e2a2 --- /dev/null +++ b/LibreOJ/133/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:309828e9b6011093be8d8268817db5d152fbe3ae6b0f50da1cde80b6d7f027fe +size 1203805