diff --git a/LibreOJ/6277/6277.cpp b/LibreOJ/6277/6277.cpp new file mode 100644 index 00000000..d09f9364 --- /dev/null +++ b/LibreOJ/6277/6277.cpp @@ -0,0 +1,65 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 50005; + +int n, b, a[N], pos[N], st[N], ed[N], add[N]; + +void change(int l, int r, int d) { + int p = pos[l], q = pos[r]; + + if (p == q) { + for (int i = l; i <= r; i++) { + a[i] += d; + } + + return; + } + + for (int i = p + 1; i <= q - 1; i++) add[i] += d; + for (int i = l; i <= ed[p]; i++) a[i] += d; + for (int i = st[q]; i <= r; i++) a[i] += d; +} + +int main() { + std::ios::sync_with_stdio(false); + + cin >> n; + + b = std::sqrt(n); + for (int i = 1; i <= b; i++) { + st[i] = (i - 1) * b + 1; + ed[i] = i * b; + } + if (ed[b] < n) { + b++; + st[b] = ed[b - 1] + 1; + ed[b] = n; + } + + for (int i = 1; i <= b; i++) { + for (int j = st[i]; j <= ed[i]; j++) { + pos[j] = i; + } + } + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + for (int i = 1, op, l, r, d; i <= n; i++) { + cin >> op >> l >> r >> d; + + if (op == 0) { + change(l, r, d); + } else { // op == 1 + cout << a[r] + add[pos[r]] << endl; + } + } + + return 0; +} diff --git a/LibreOJ/6277/data/a1.in b/LibreOJ/6277/data/a1.in new file mode 100644 index 00000000..9a0dce5b --- /dev/null +++ b/LibreOJ/6277/data/a1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0c49765353d4e19a0811ff3a8c16454e07a74ca45fddf02dc629419867b5ab2 +size 106630 diff --git a/LibreOJ/6277/data/a1.out b/LibreOJ/6277/data/a1.out new file mode 100644 index 00000000..1d325475 --- /dev/null +++ b/LibreOJ/6277/data/a1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d937f5a41e2ed1bcf1f3ade90b8925025bf52de55d357577324d640d8beec86 +size 18759 diff --git a/LibreOJ/6277/data/a10.in b/LibreOJ/6277/data/a10.in new file mode 100644 index 00000000..126dfc44 --- /dev/null +++ b/LibreOJ/6277/data/a10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d4b0743528b6b2b6dec1924877fea00f4d5bbde3ce4f0143a831878a24eefc1 +size 1166327 diff --git a/LibreOJ/6277/data/a10.out b/LibreOJ/6277/data/a10.out new file mode 100644 index 00000000..494c20fe --- /dev/null +++ b/LibreOJ/6277/data/a10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7aca038f82b94c5c187212c3462696e1b5eab3f09dcbaec66301af1591cd79b3 +size 215897 diff --git a/LibreOJ/6277/data/a2.in b/LibreOJ/6277/data/a2.in new file mode 100644 index 00000000..9a0dce5b --- /dev/null +++ b/LibreOJ/6277/data/a2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0c49765353d4e19a0811ff3a8c16454e07a74ca45fddf02dc629419867b5ab2 +size 106630 diff --git a/LibreOJ/6277/data/a2.out b/LibreOJ/6277/data/a2.out new file mode 100644 index 00000000..1d325475 --- /dev/null +++ b/LibreOJ/6277/data/a2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d937f5a41e2ed1bcf1f3ade90b8925025bf52de55d357577324d640d8beec86 +size 18759 diff --git a/LibreOJ/6277/data/a3.in b/LibreOJ/6277/data/a3.in new file mode 100644 index 00000000..8f7a6467 --- /dev/null +++ b/LibreOJ/6277/data/a3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62140209d48c68471d8adb0d7c9afd64d7c43899bbe26e1bd86084e510750a52 +size 106787 diff --git a/LibreOJ/6277/data/a3.out b/LibreOJ/6277/data/a3.out new file mode 100644 index 00000000..b2441513 --- /dev/null +++ b/LibreOJ/6277/data/a3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b758f4f6ce511db6334023a6a44a539f45ed3fff8bdd2bcec3f6483e088aadc6 +size 19242 diff --git a/LibreOJ/6277/data/a4.in b/LibreOJ/6277/data/a4.in new file mode 100644 index 00000000..67701cf7 --- /dev/null +++ b/LibreOJ/6277/data/a4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e36644e2a5c7e0107564826a55d82e38d8054685a4f441be584010c2f5da30e2 +size 1166550 diff --git a/LibreOJ/6277/data/a4.out b/LibreOJ/6277/data/a4.out new file mode 100644 index 00000000..1cf46b22 --- /dev/null +++ b/LibreOJ/6277/data/a4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0a3303da15a482b5bb9c753cacfa2c2863b21fb164af7094381b872545849fd +size 214848 diff --git a/LibreOJ/6277/data/a5.in b/LibreOJ/6277/data/a5.in new file mode 100644 index 00000000..0069aba1 --- /dev/null +++ b/LibreOJ/6277/data/a5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a30a5d249b651e5d31de93c67d0422967fd03bac62a8fbfe0c7146da107b5e7 +size 1166917 diff --git a/LibreOJ/6277/data/a5.out b/LibreOJ/6277/data/a5.out new file mode 100644 index 00000000..a1528eab --- /dev/null +++ b/LibreOJ/6277/data/a5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5dbbaa8c3e702c555e5a07e6a639b1eda18809e81c566db6f2332bffd6ed81d9 +size 216371 diff --git a/LibreOJ/6277/data/a6.in b/LibreOJ/6277/data/a6.in new file mode 100644 index 00000000..55b47108 --- /dev/null +++ b/LibreOJ/6277/data/a6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4422d8e0339f0cca21229d696a0cff59a9782a601d860b3e9e7ac95bdec58755 +size 1166429 diff --git a/LibreOJ/6277/data/a6.out b/LibreOJ/6277/data/a6.out new file mode 100644 index 00000000..86f2ece5 --- /dev/null +++ b/LibreOJ/6277/data/a6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d0257cc77f514473e7f69c9f2ff2205749a5bc96d85b412f3a6ab2d5bedf249 +size 213238 diff --git a/LibreOJ/6277/data/a7.in b/LibreOJ/6277/data/a7.in new file mode 100644 index 00000000..4fc7c7eb --- /dev/null +++ b/LibreOJ/6277/data/a7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f984f228613850789ef45667790a47414a1e880e2ebd1069075827fd7ebf5498 +size 1166901 diff --git a/LibreOJ/6277/data/a7.out b/LibreOJ/6277/data/a7.out new file mode 100644 index 00000000..53f8ec44 --- /dev/null +++ b/LibreOJ/6277/data/a7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc87358b8181718efbff22e21d5155ca06d97a6e55545f4891ae8b8fdab08614 +size 215708 diff --git a/LibreOJ/6277/data/a8.in b/LibreOJ/6277/data/a8.in new file mode 100644 index 00000000..0df52a63 --- /dev/null +++ b/LibreOJ/6277/data/a8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b43d31460b3fea56ed75fc6522ca4f6cb8da028c64f341a7a2611e7254cf941 +size 1166676 diff --git a/LibreOJ/6277/data/a8.out b/LibreOJ/6277/data/a8.out new file mode 100644 index 00000000..b64e5d84 --- /dev/null +++ b/LibreOJ/6277/data/a8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bec64dc39b8a248091a0b51ad3ab67a631bd6cd0f1dda689a19fb9c6d774da53 +size 214544 diff --git a/LibreOJ/6277/data/a9.in b/LibreOJ/6277/data/a9.in new file mode 100644 index 00000000..f449b467 --- /dev/null +++ b/LibreOJ/6277/data/a9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:684d2f8509b4b1545531d1987e07255cc80a92cd12c6fff0eb0091dc152bbf65 +size 1166871 diff --git a/LibreOJ/6277/data/a9.out b/LibreOJ/6277/data/a9.out new file mode 100644 index 00000000..b352c496 --- /dev/null +++ b/LibreOJ/6277/data/a9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0f1833391b1f45a2d111c03b5ce24a577d1998af622a2280d11130ce2c75a39 +size 214035