From fb4eafdc6eca196f8a96638a11c8c379d041d472 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Fri, 16 Dec 2022 21:13:26 +0800 Subject: [PATCH] =?UTF-8?q?#3043.=20=E3=80=8CZJOI2019=E3=80=8D=E7=BA=BF?= =?UTF-8?q?=E6=AE=B5=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1654289 --- LibreOJ/3043/3043.cpp | 124 ++++++++++++++++++++++++++++++++ LibreOJ/3043/data/segment1.ans | 3 + LibreOJ/3043/data/segment1.in | 3 + LibreOJ/3043/data/segment10.ans | 3 + LibreOJ/3043/data/segment10.in | 3 + LibreOJ/3043/data/segment2.ans | 3 + LibreOJ/3043/data/segment2.in | 3 + LibreOJ/3043/data/segment3.ans | 3 + LibreOJ/3043/data/segment3.in | 3 + LibreOJ/3043/data/segment4.ans | 3 + LibreOJ/3043/data/segment4.in | 3 + LibreOJ/3043/data/segment5.ans | 3 + LibreOJ/3043/data/segment5.in | 3 + LibreOJ/3043/data/segment6.ans | 3 + LibreOJ/3043/data/segment6.in | 3 + LibreOJ/3043/data/segment7.ans | 3 + LibreOJ/3043/data/segment7.in | 3 + LibreOJ/3043/data/segment8.ans | 3 + LibreOJ/3043/data/segment8.in | 3 + LibreOJ/3043/data/segment9.ans | 3 + LibreOJ/3043/data/segment9.in | 3 + 21 files changed, 184 insertions(+) create mode 100644 LibreOJ/3043/3043.cpp create mode 100644 LibreOJ/3043/data/segment1.ans create mode 100644 LibreOJ/3043/data/segment1.in create mode 100644 LibreOJ/3043/data/segment10.ans create mode 100644 LibreOJ/3043/data/segment10.in create mode 100644 LibreOJ/3043/data/segment2.ans create mode 100644 LibreOJ/3043/data/segment2.in create mode 100644 LibreOJ/3043/data/segment3.ans create mode 100644 LibreOJ/3043/data/segment3.in create mode 100644 LibreOJ/3043/data/segment4.ans create mode 100644 LibreOJ/3043/data/segment4.in create mode 100644 LibreOJ/3043/data/segment5.ans create mode 100644 LibreOJ/3043/data/segment5.in create mode 100644 LibreOJ/3043/data/segment6.ans create mode 100644 LibreOJ/3043/data/segment6.in create mode 100644 LibreOJ/3043/data/segment7.ans create mode 100644 LibreOJ/3043/data/segment7.in create mode 100644 LibreOJ/3043/data/segment8.ans create mode 100644 LibreOJ/3043/data/segment8.in create mode 100644 LibreOJ/3043/data/segment9.ans create mode 100644 LibreOJ/3043/data/segment9.in diff --git a/LibreOJ/3043/3043.cpp b/LibreOJ/3043/3043.cpp new file mode 100644 index 00000000..e6d23622 --- /dev/null +++ b/LibreOJ/3043/3043.cpp @@ -0,0 +1,124 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1e5 + 5; +const int mod = 998244353; + +int n, m, delta = 1, sum, ans; + +struct node { + int l, r, f, s, tag_f_add, tag_f_mul, tag_s_mul; + + node(const int &_l = 0, const int &_r = 0) + : l(_l), r(_r), f(0), s(0), tag_f_add(0), tag_f_mul(1), tag_s_mul(1) {} +} tr[N << 2]; + +void build(int u, int l, int r) { + tr[u] = node(l, r); + + if (l == r) return; + + int mid = l + r >> 1; + + build(u << 1, l, mid); + build(u << 1 | 1, mid + 1, r); +} + +void push_f_add(int u, int v) { + tr[u].tag_f_add = (static_cast(tr[u].tag_f_add) + v) % mod; + tr[u].f = (static_cast(tr[u].f) + v) % mod; +} + +void push_f_mul(int u, int v) { + tr[u].f = static_cast(tr[u].f) * v % mod; + tr[u].tag_f_mul = static_cast(tr[u].tag_f_mul) * v % mod; + tr[u].tag_f_add = static_cast(tr[u].tag_f_add) * v % mod; +} + +void push_s_mul(int u, int v) { + tr[u].s = static_cast(tr[u].s) * v % mod; + tr[u].tag_s_mul = static_cast(tr[u].tag_s_mul) * v % mod; +} + +void pushdown(int u) { + if (tr[u].tag_f_mul != 1) { + push_f_mul(u << 1, tr[u].tag_f_mul); + push_f_mul(u << 1 | 1, tr[u].tag_f_mul); + tr[u].tag_f_mul = 1; + } + + if (tr[u].tag_s_mul != 1) { + push_s_mul(u << 1, tr[u].tag_s_mul); + push_s_mul(u << 1 | 1, tr[u].tag_s_mul); + tr[u].tag_s_mul = 1; + } + + if (tr[u].tag_f_add != 0) { + push_f_add(u << 1, tr[u].tag_f_add); + push_f_add(u << 1 | 1, tr[u].tag_f_add); + tr[u].tag_f_add = 0; + } +} + +void modify(int u, int l, int r) { + if (l <= tr[u].l && tr[u].r <= r) { + ans = (((static_cast(ans) - tr[u].s) % mod) + mod) % mod; + tr[u].s = (static_cast(tr[u].s) + delta) % mod; + tr[u].tag_s_mul = (static_cast(tr[u].tag_s_mul) * 2) % mod; + push_f_add(u, delta); + sum = (static_cast(sum) + tr[u].s) % mod; + + return; + } + + if (tr[u].l > r || tr[u].r < l) { + ans = (((static_cast(ans) - tr[u].s) % mod) + mod) % mod; + tr[u].s = (static_cast(tr[u].s) + tr[u].f) % mod; + tr[u].tag_s_mul = (static_cast(tr[u].tag_s_mul) * 2) % mod; + push_f_mul(u, 2); + sum = (static_cast(sum) + tr[u].s) % mod; + + return; + } + + pushdown(u); + + ans = (((static_cast(ans) - tr[u].s) % mod) + mod) % mod; + sum = (static_cast(sum) + tr[u].s) % mod; + + modify(u << 1, l, r); + modify(u << 1 | 1, l, r); +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m; + + build(1, 1, n); + + while (m--) { + int op; + + cin >> op; + + if (op == 1) { + int l, r; + + cin >> l >> r; + + sum = 0; + modify(1, l, r); + ans = (2ll * ans + sum) % mod; + delta = 2ll * delta % mod; + } else { // op == 2 + cout << ans << endl; + } + } + + return 0; +} diff --git a/LibreOJ/3043/data/segment1.ans b/LibreOJ/3043/data/segment1.ans new file mode 100644 index 00000000..17769868 --- /dev/null +++ b/LibreOJ/3043/data/segment1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c1cd54d1582d4eaac512daac2864728287e7828c0af209b22bee9c064f1f90f +size 8 diff --git a/LibreOJ/3043/data/segment1.in b/LibreOJ/3043/data/segment1.in new file mode 100644 index 00000000..e47585a4 --- /dev/null +++ b/LibreOJ/3043/data/segment1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d998e8c8c829eab90e1671d51d70ab578e7c9f3d41fb0b648d0f6af5577f47c +size 61 diff --git a/LibreOJ/3043/data/segment10.ans b/LibreOJ/3043/data/segment10.ans new file mode 100644 index 00000000..19cffa43 --- /dev/null +++ b/LibreOJ/3043/data/segment10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f853c789cb2b38df96910d4f7330dc386b6cf812b1b3a778f1c61a251b0fb9a6 +size 141470 diff --git a/LibreOJ/3043/data/segment10.in b/LibreOJ/3043/data/segment10.in new file mode 100644 index 00000000..d90b8e92 --- /dev/null +++ b/LibreOJ/3043/data/segment10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78ae304d7cb7966a3e45c0be05ba638c299aadf753505a1cbf4870e287c82504 +size 1209104 diff --git a/LibreOJ/3043/data/segment2.ans b/LibreOJ/3043/data/segment2.ans new file mode 100644 index 00000000..fb2ad3bf --- /dev/null +++ b/LibreOJ/3043/data/segment2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6efc7f957dd239e714ab122f98240aa6c9e909b05d97c20f0d9e597ea0d3996c +size 8 diff --git a/LibreOJ/3043/data/segment2.in b/LibreOJ/3043/data/segment2.in new file mode 100644 index 00000000..f8bbda00 --- /dev/null +++ b/LibreOJ/3043/data/segment2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:613855e98bd23ba922ac834ad248bd2dd3917b77cc7edb77df32fbb673c810f2 +size 63 diff --git a/LibreOJ/3043/data/segment3.ans b/LibreOJ/3043/data/segment3.ans new file mode 100644 index 00000000..9545a963 --- /dev/null +++ b/LibreOJ/3043/data/segment3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0959a12b331c0b468e987e2764faad294c206a34d665c642187b99a64a1d3063 +size 1258 diff --git a/LibreOJ/3043/data/segment3.in b/LibreOJ/3043/data/segment3.in new file mode 100644 index 00000000..c640e5c8 --- /dev/null +++ b/LibreOJ/3043/data/segment3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1d52772c3acdbd5f38701b1761bcdcc2aecbdb7d37bb98201aa23b5470607a8 +size 8781 diff --git a/LibreOJ/3043/data/segment4.ans b/LibreOJ/3043/data/segment4.ans new file mode 100644 index 00000000..92fac8e6 --- /dev/null +++ b/LibreOJ/3043/data/segment4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3082d3fec361013e0631b0325db5c3af843c6541a3c7463a7d69b877929bbcf7 +size 1252 diff --git a/LibreOJ/3043/data/segment4.in b/LibreOJ/3043/data/segment4.in new file mode 100644 index 00000000..f072de5e --- /dev/null +++ b/LibreOJ/3043/data/segment4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b9e00f141d366972bde4c0536df0f0a7a81b05f0969d1efb1470bee39ff6eb2 +size 8794 diff --git a/LibreOJ/3043/data/segment5.ans b/LibreOJ/3043/data/segment5.ans new file mode 100644 index 00000000..ffad8e29 --- /dev/null +++ b/LibreOJ/3043/data/segment5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7212ba5436b161c0a789968d916e904b38648f3d6211566312c87555316cd2a5 +size 10 diff --git a/LibreOJ/3043/data/segment5.in b/LibreOJ/3043/data/segment5.in new file mode 100644 index 00000000..115dc279 --- /dev/null +++ b/LibreOJ/3043/data/segment5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02315bda20258f334e5705fbc0d9b6ee4355cc614891782c66f2b8c2e215ac0e +size 1377302 diff --git a/LibreOJ/3043/data/segment6.ans b/LibreOJ/3043/data/segment6.ans new file mode 100644 index 00000000..10bdbf55 --- /dev/null +++ b/LibreOJ/3043/data/segment6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e384791844558aa2f606910fd4e50aedcd03e2c3f5f8fc761a839f8fc224921c +size 10 diff --git a/LibreOJ/3043/data/segment6.in b/LibreOJ/3043/data/segment6.in new file mode 100644 index 00000000..7a663237 --- /dev/null +++ b/LibreOJ/3043/data/segment6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f22e95df97b9d8f924d931041230813560c47ba5ed3b9b52a1c2be52be0e15d +size 1377377 diff --git a/LibreOJ/3043/data/segment7.ans b/LibreOJ/3043/data/segment7.ans new file mode 100644 index 00000000..2b7351e1 --- /dev/null +++ b/LibreOJ/3043/data/segment7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5fdb66f25d441b70c21546dade9f6e73583dd66fe1e91654cf8d021d82be20d +size 10 diff --git a/LibreOJ/3043/data/segment7.in b/LibreOJ/3043/data/segment7.in new file mode 100644 index 00000000..37cb294f --- /dev/null +++ b/LibreOJ/3043/data/segment7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d8dedf1c67bb7afa58818a1e04a21143794ebabb013f9ce339455f2f0127073 +size 1377604 diff --git a/LibreOJ/3043/data/segment8.ans b/LibreOJ/3043/data/segment8.ans new file mode 100644 index 00000000..00f76561 --- /dev/null +++ b/LibreOJ/3043/data/segment8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ad6bdb4b3205db84334bf5078ee215eaaa04749c83b9c2cb8298d0f883af10e +size 141963 diff --git a/LibreOJ/3043/data/segment8.in b/LibreOJ/3043/data/segment8.in new file mode 100644 index 00000000..c24f4e72 --- /dev/null +++ b/LibreOJ/3043/data/segment8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:46fd04ac5b7deb9143d07d5d39dea11e3262a0218cd289e6954421688176c853 +size 1207675 diff --git a/LibreOJ/3043/data/segment9.ans b/LibreOJ/3043/data/segment9.ans new file mode 100644 index 00000000..f9559670 --- /dev/null +++ b/LibreOJ/3043/data/segment9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:422ec7fc6944676f13d6f852fef22a693ae543761349dc3d9578470a852c50d6 +size 140605 diff --git a/LibreOJ/3043/data/segment9.in b/LibreOJ/3043/data/segment9.in new file mode 100644 index 00000000..89b4627a --- /dev/null +++ b/LibreOJ/3043/data/segment9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fbd9c7a6a7c3f8b6b1170ef19c2b8d9ab5f283298907ae13ef4e5a4df9f48876 +size 1209698