From 041499d4c033e084211f4fcb3cc1c04d16791ffb Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 18 May 2022 16:15:38 +0800 Subject: [PATCH] =?UTF-8?q?#6280.=20=E6=95=B0=E5=88=97=E5=88=86=E5=9D=97?= =?UTF-8?q?=E5=85=A5=E9=97=A8=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1465673 --- LibreOJ/6280/6280.cpp | 92 +++++++++++++++++++++++++++++++++++++++ LibreOJ/6280/data/a1.in | 3 ++ LibreOJ/6280/data/a1.out | 3 ++ LibreOJ/6280/data/a10.in | 3 ++ LibreOJ/6280/data/a10.out | 3 ++ LibreOJ/6280/data/a2.in | 3 ++ LibreOJ/6280/data/a2.out | 3 ++ LibreOJ/6280/data/a3.in | 3 ++ LibreOJ/6280/data/a3.out | 3 ++ LibreOJ/6280/data/a4.in | 3 ++ LibreOJ/6280/data/a4.out | 3 ++ LibreOJ/6280/data/a5.in | 3 ++ LibreOJ/6280/data/a5.out | 3 ++ LibreOJ/6280/data/a6.in | 3 ++ LibreOJ/6280/data/a6.out | 3 ++ LibreOJ/6280/data/a7.in | 3 ++ LibreOJ/6280/data/a7.out | 3 ++ LibreOJ/6280/data/a8.in | 3 ++ LibreOJ/6280/data/a8.out | 3 ++ LibreOJ/6280/data/a9.in | 3 ++ LibreOJ/6280/data/a9.out | 3 ++ 21 files changed, 152 insertions(+) create mode 100644 LibreOJ/6280/6280.cpp create mode 100644 LibreOJ/6280/data/a1.in create mode 100644 LibreOJ/6280/data/a1.out create mode 100644 LibreOJ/6280/data/a10.in create mode 100644 LibreOJ/6280/data/a10.out create mode 100644 LibreOJ/6280/data/a2.in create mode 100644 LibreOJ/6280/data/a2.out create mode 100644 LibreOJ/6280/data/a3.in create mode 100644 LibreOJ/6280/data/a3.out create mode 100644 LibreOJ/6280/data/a4.in create mode 100644 LibreOJ/6280/data/a4.out create mode 100644 LibreOJ/6280/data/a5.in create mode 100644 LibreOJ/6280/data/a5.out create mode 100644 LibreOJ/6280/data/a6.in create mode 100644 LibreOJ/6280/data/a6.out create mode 100644 LibreOJ/6280/data/a7.in create mode 100644 LibreOJ/6280/data/a7.out create mode 100644 LibreOJ/6280/data/a8.in create mode 100644 LibreOJ/6280/data/a8.out create mode 100644 LibreOJ/6280/data/a9.in create mode 100644 LibreOJ/6280/data/a9.out diff --git a/LibreOJ/6280/6280.cpp b/LibreOJ/6280/6280.cpp new file mode 100644 index 00000000..9423c61b --- /dev/null +++ b/LibreOJ/6280/6280.cpp @@ -0,0 +1,92 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 50005; + +int n, t, c, a[N], st[N], ed[N], pos[N]; +long long sum[N], add[N]; + +void change(int l, int r, int c) { + int p = pos[l], + q = pos[r]; + + if (p == q) { + for (int i = l; i <= r; i++) { + a[i] += c; + } + sum[p] += (r - l + 1) * c; + + return; + } + + for (int i = l; i <= ed[p]; i++) a[i] += c; + sum[p] += (ed[p] - l + 1) * c; + + for (int i = st[q]; i <= r; i++) a[i] += c; + sum[q] += (r - st[q] + 1) * c; + + for (int i = p + 1; i <= q - 1; i++) add[i] += c; +} + +int query(int l, int r, int c) { + int p = pos[l], + q = pos[r]; + int res = 0; + + if (p == q) { + for (int i = l; i <= r; i++) { + res = (res + a[i] + add[p]) % (c + 1); + } + + return res; + } + + for (int i = l; i <= ed[p]; i++) res = (res + a[i] + add[p]) % (c + 1); + for (int i = st[q]; i <= r; i++) res = (res + a[i] + add[q]) % (c + 1); + + for (int i = p + 1; i <= q - 1; i++) res = (res + sum[i] + 1ll * add[i] * t) % (c + 1); + + return res; +} + +int main() { + std::ios::sync_with_stdio(false); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + t = std::sqrt(n); + + for (c = 1;; c++) { + st[c] = (c - 1) * t + 1; + ed[c] = std::min(n, t * c); + + if (t * c >= n) break; + } + + for (int i = 1; i <= c; i++) { + for (int j = st[i]; j <= ed[i]; j++) { + pos[j] = i; + sum[i] += a[j]; + } + } + + for (int i = 1, op, l, r, c; i <= n; i++) { + cin >> op >> l >> r >> c; + + if (op == 0) { + change(l, r, c); + } else { // op == 1 + cout << query(l, r, c) % (c + 1) << endl; + } + } + + return 0; +} diff --git a/LibreOJ/6280/data/a1.in b/LibreOJ/6280/data/a1.in new file mode 100644 index 00000000..9a0dce5b --- /dev/null +++ b/LibreOJ/6280/data/a1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0c49765353d4e19a0811ff3a8c16454e07a74ca45fddf02dc629419867b5ab2 +size 106630 diff --git a/LibreOJ/6280/data/a1.out b/LibreOJ/6280/data/a1.out new file mode 100644 index 00000000..2c62a091 --- /dev/null +++ b/LibreOJ/6280/data/a1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd51b085b8e0010bab2e8797d6f72bc0ea8cc04345523732cc9a63492782602c +size 11394 diff --git a/LibreOJ/6280/data/a10.in b/LibreOJ/6280/data/a10.in new file mode 100644 index 00000000..126dfc44 --- /dev/null +++ b/LibreOJ/6280/data/a10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d4b0743528b6b2b6dec1924877fea00f4d5bbde3ce4f0143a831878a24eefc1 +size 1166327 diff --git a/LibreOJ/6280/data/a10.out b/LibreOJ/6280/data/a10.out new file mode 100644 index 00000000..408b5924 --- /dev/null +++ b/LibreOJ/6280/data/a10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96ca8e24664910afd941ff8a0b9c98b344c26b0ee9bd1a2f04ba19d624d41d14 +size 115526 diff --git a/LibreOJ/6280/data/a2.in b/LibreOJ/6280/data/a2.in new file mode 100644 index 00000000..9a0dce5b --- /dev/null +++ b/LibreOJ/6280/data/a2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0c49765353d4e19a0811ff3a8c16454e07a74ca45fddf02dc629419867b5ab2 +size 106630 diff --git a/LibreOJ/6280/data/a2.out b/LibreOJ/6280/data/a2.out new file mode 100644 index 00000000..2c62a091 --- /dev/null +++ b/LibreOJ/6280/data/a2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd51b085b8e0010bab2e8797d6f72bc0ea8cc04345523732cc9a63492782602c +size 11394 diff --git a/LibreOJ/6280/data/a3.in b/LibreOJ/6280/data/a3.in new file mode 100644 index 00000000..8f7a6467 --- /dev/null +++ b/LibreOJ/6280/data/a3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62140209d48c68471d8adb0d7c9afd64d7c43899bbe26e1bd86084e510750a52 +size 106787 diff --git a/LibreOJ/6280/data/a3.out b/LibreOJ/6280/data/a3.out new file mode 100644 index 00000000..1ab5d60b --- /dev/null +++ b/LibreOJ/6280/data/a3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12b7567ce031a2d85e29e69dc3b965043cf5d1bb33c1a49f374510a5e6d71b9a +size 11616 diff --git a/LibreOJ/6280/data/a4.in b/LibreOJ/6280/data/a4.in new file mode 100644 index 00000000..67701cf7 --- /dev/null +++ b/LibreOJ/6280/data/a4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e36644e2a5c7e0107564826a55d82e38d8054685a4f441be584010c2f5da30e2 +size 1166550 diff --git a/LibreOJ/6280/data/a4.out b/LibreOJ/6280/data/a4.out new file mode 100644 index 00000000..206e32ba --- /dev/null +++ b/LibreOJ/6280/data/a4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2564fc9da28e16acf3de6a243a62c637affecefae4c2cfe46450b182427b3fc +size 114839 diff --git a/LibreOJ/6280/data/a5.in b/LibreOJ/6280/data/a5.in new file mode 100644 index 00000000..0069aba1 --- /dev/null +++ b/LibreOJ/6280/data/a5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a30a5d249b651e5d31de93c67d0422967fd03bac62a8fbfe0c7146da107b5e7 +size 1166917 diff --git a/LibreOJ/6280/data/a5.out b/LibreOJ/6280/data/a5.out new file mode 100644 index 00000000..7d1a265f --- /dev/null +++ b/LibreOJ/6280/data/a5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17a06088fb81fe628d8f7ac99a072596b849bb1c7c2ef138d054339deeee7907 +size 115974 diff --git a/LibreOJ/6280/data/a6.in b/LibreOJ/6280/data/a6.in new file mode 100644 index 00000000..55b47108 --- /dev/null +++ b/LibreOJ/6280/data/a6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4422d8e0339f0cca21229d696a0cff59a9782a601d860b3e9e7ac95bdec58755 +size 1166429 diff --git a/LibreOJ/6280/data/a6.out b/LibreOJ/6280/data/a6.out new file mode 100644 index 00000000..4f58ed63 --- /dev/null +++ b/LibreOJ/6280/data/a6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7cd93eac9aab5107c8940926e09ef0bc3edb99ed9e46537cea891df8649cc54 +size 114101 diff --git a/LibreOJ/6280/data/a7.in b/LibreOJ/6280/data/a7.in new file mode 100644 index 00000000..4fc7c7eb --- /dev/null +++ b/LibreOJ/6280/data/a7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f984f228613850789ef45667790a47414a1e880e2ebd1069075827fd7ebf5498 +size 1166901 diff --git a/LibreOJ/6280/data/a7.out b/LibreOJ/6280/data/a7.out new file mode 100644 index 00000000..28661e29 --- /dev/null +++ b/LibreOJ/6280/data/a7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b0c1f599b374d5939339e47f93cb7334315de3ca20f5477eb247cc7ce30c5f82 +size 115598 diff --git a/LibreOJ/6280/data/a8.in b/LibreOJ/6280/data/a8.in new file mode 100644 index 00000000..0df52a63 --- /dev/null +++ b/LibreOJ/6280/data/a8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b43d31460b3fea56ed75fc6522ca4f6cb8da028c64f341a7a2611e7254cf941 +size 1166676 diff --git a/LibreOJ/6280/data/a8.out b/LibreOJ/6280/data/a8.out new file mode 100644 index 00000000..4282cf95 --- /dev/null +++ b/LibreOJ/6280/data/a8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b926f00c1bb260b23f5b36ca064ebed8a8219980b1e33bb71d20216e8dcb400d +size 115063 diff --git a/LibreOJ/6280/data/a9.in b/LibreOJ/6280/data/a9.in new file mode 100644 index 00000000..f449b467 --- /dev/null +++ b/LibreOJ/6280/data/a9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:684d2f8509b4b1545531d1987e07255cc80a92cd12c6fff0eb0091dc152bbf65 +size 1166871 diff --git a/LibreOJ/6280/data/a9.out b/LibreOJ/6280/data/a9.out new file mode 100644 index 00000000..851b43d9 --- /dev/null +++ b/LibreOJ/6280/data/a9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f42e0a7a0dac90f635d9c2f121dd00f29add3a46b3e0dd9d603dd624e04d7fc6 +size 114481