diff --git a/LibreOJ/3110/3110.cpp b/LibreOJ/3110/3110.cpp new file mode 100644 index 00000000..417f5395 --- /dev/null +++ b/LibreOJ/3110/3110.cpp @@ -0,0 +1,97 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int Q = 1e5 + 5; +const int mod = 1e7 + 19; + +int n, q, t, inv[mod], add, mul = 1, sum, ans; +std::tuple ops[Q]; +std::unordered_map map; + +int get(int x) { + return (static_cast(map.count(x) ? map[x] : 0) * mul + add) % mod; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + inv[1] = 1; + for (int i = 2; i < mod; i++) { + inv[i] = static_cast(mod - mod / i) * inv[mod % i] % mod; + } + + cin >> n >> q; + + for (int i = 1, x, v; i <= q; i++) { + cin >> x; + + std::get<0>(ops[i]) = x; + + if (x == 1) { + cin >> std::get<1>(ops[i]) >> v; + + std::get<2>(ops[i]) = (v % mod + mod) % mod; + } else if (x <= 5) { + cin >> v; + + std::get<1>(ops[i]) = (v % mod + mod) % mod; + } + + if (x == 3 && std::get<1>(ops[i]) == 0) { + std::get<0>(ops[i]) = 4; + } + } + + cin >> t; + + for (int i = 1, a, b; i <= t; i++) { + cin >> a >> b; + + for (int j = 1; j <= q; j++) { + int id = (a + static_cast(j) * b) % q + 1; + int op = std::get<0>(ops[id]); + + if (op == 1) { + int index = std::get<1>(ops[id]), + value = std::get<2>(ops[id]); + + sum = ((sum - get(index)) % mod + mod) % mod; + map[index] = (static_cast(value - add) * inv[mul] % mod + mod) % mod; + sum = ((sum + value) % mod + mod) % mod; + } else if (op == 2) { + int value = std::get<1>(ops[id]); + + add = ((add + value) % mod + mod) % mod; + sum = ((sum + static_cast(value) * n % mod) % mod + mod) % mod; + } else if (op == 3) { + int value = std::get<1>(ops[id]); + + mul = (static_cast(mul) * value % mod + mod) % mod; + add = (static_cast(add) * value % mod + mod) % mod; + sum = (static_cast(sum) * value % mod + mod) % mod; + } else if (op == 4) { + int value = std::get<1>(ops[id]); + + mul = 1; + add = value; + sum = (static_cast(value) * n % mod + mod) % mod; + map.clear(); + } else if (op == 5) { + int index = std::get<1>(ops[id]); + + ans = ((ans + get(index)) % mod + mod) % mod; + } else { // op == 6 + ans = ((ans + sum) % mod + mod) % mod; + } + } + } + + cout << (ans % mod + mod) % mod << endl; + + return 0; +} diff --git a/LibreOJ/3110/data/02 b/LibreOJ/3110/data/02 new file mode 100644 index 00000000..fdc24c6f --- /dev/null +++ b/LibreOJ/3110/data/02 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53e9696b77da7d3e02376eb8540621aad56a8c0c5fffc1a110c6c371a0eb5169 +size 1627431 diff --git a/LibreOJ/3110/data/02.a b/LibreOJ/3110/data/02.a new file mode 100644 index 00000000..b5b12abe --- /dev/null +++ b/LibreOJ/3110/data/02.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33d58138d3e9e537cc19861f1131d87bed8fe7832e9a958e99f0f9bd661a97ab +size 9 diff --git a/LibreOJ/3110/data/03 b/LibreOJ/3110/data/03 new file mode 100644 index 00000000..84505009 --- /dev/null +++ b/LibreOJ/3110/data/03 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fce74b5fb0aad00e8f28e6b49114821a5c9f0b2acecd6de52d602d46d927e6e6 +size 1583607 diff --git a/LibreOJ/3110/data/03.a b/LibreOJ/3110/data/03.a new file mode 100644 index 00000000..a95daec7 --- /dev/null +++ b/LibreOJ/3110/data/03.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd41e09dfe2009992bf365d1cfa78f3d2b1c1e02d77e71311412618c0dbc7be5 +size 9 diff --git a/LibreOJ/3110/data/04 b/LibreOJ/3110/data/04 new file mode 100644 index 00000000..ed5d2f77 --- /dev/null +++ b/LibreOJ/3110/data/04 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c63403c0c5be6c589201e25103b37c76da4f919f1d0134aa7ae0dc66e1133987 +size 1677764 diff --git a/LibreOJ/3110/data/04.a b/LibreOJ/3110/data/04.a new file mode 100644 index 00000000..b4f0ffeb --- /dev/null +++ b/LibreOJ/3110/data/04.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4dfe04446ab428c8da1f6e3154fce7302680f49718b5f638b051640187879bb +size 9 diff --git a/LibreOJ/3110/data/05 b/LibreOJ/3110/data/05 new file mode 100644 index 00000000..049d6890 --- /dev/null +++ b/LibreOJ/3110/data/05 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a88dc62ad37b8df01dda6a5588bb0e8ab04fb0a5d8ebc8b9ced4dfe085e20fe +size 1662189 diff --git a/LibreOJ/3110/data/05.a b/LibreOJ/3110/data/05.a new file mode 100644 index 00000000..cdac2dcc --- /dev/null +++ b/LibreOJ/3110/data/05.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:008637b13c25f861481576c5524101aad52269db0071dc952ce0ab3b2198bba9 +size 9 diff --git a/LibreOJ/3110/data/06 b/LibreOJ/3110/data/06 new file mode 100644 index 00000000..489f9a24 --- /dev/null +++ b/LibreOJ/3110/data/06 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f7c9fc22aa3471dd978babac0a13201ac90292ebeed91e6652a95a79a184ec7c +size 1548559 diff --git a/LibreOJ/3110/data/06.a b/LibreOJ/3110/data/06.a new file mode 100644 index 00000000..78479d99 --- /dev/null +++ b/LibreOJ/3110/data/06.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3508eac386b8846a7551e5e54e3751434ec9faffc7f09fa8e99a7b6d50989027 +size 9 diff --git a/LibreOJ/3110/data/07 b/LibreOJ/3110/data/07 new file mode 100644 index 00000000..3cd27914 --- /dev/null +++ b/LibreOJ/3110/data/07 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1308112d37ba04c4cb7e59b8d53ad99ccb147dbcaf4606fd782e114675bc26bd +size 1919750 diff --git a/LibreOJ/3110/data/07.a b/LibreOJ/3110/data/07.a new file mode 100644 index 00000000..71c22dff --- /dev/null +++ b/LibreOJ/3110/data/07.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65af0eac2efbe4e58043d95b5b491480bea4f6dc870c696c3ec1f25af67fdc67 +size 9 diff --git a/LibreOJ/3110/data/08 b/LibreOJ/3110/data/08 new file mode 100644 index 00000000..1765f8f2 --- /dev/null +++ b/LibreOJ/3110/data/08 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:45fd9320f4a0993ad4705ed5d8881405bed3608e5e4d61df649875a19264eb6b +size 1827442 diff --git a/LibreOJ/3110/data/08.a b/LibreOJ/3110/data/08.a new file mode 100644 index 00000000..abc7bde7 --- /dev/null +++ b/LibreOJ/3110/data/08.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7501bf335647297e10a3b751083231170f4a3d2f10293ee450e4600d8e26461b +size 9 diff --git a/LibreOJ/3110/data/09 b/LibreOJ/3110/data/09 new file mode 100644 index 00000000..9131118a --- /dev/null +++ b/LibreOJ/3110/data/09 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:635b551e2897898654fc742c419dd544333bf7f08b356f42d1505209a385d557 +size 1777711 diff --git a/LibreOJ/3110/data/09.a b/LibreOJ/3110/data/09.a new file mode 100644 index 00000000..935285ad --- /dev/null +++ b/LibreOJ/3110/data/09.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b65e176a697b4a1b6f9a1d5dc1a14dad2bc5affa46c590a0d2d349901b8bce5 +size 9 diff --git a/LibreOJ/3110/data/10 b/LibreOJ/3110/data/10 new file mode 100644 index 00000000..33230ce3 --- /dev/null +++ b/LibreOJ/3110/data/10 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b8040882edad8f68a57103b4cfc0608815e0ac8a6b7a9aa12a26b44bc21a5e8 +size 1882240 diff --git a/LibreOJ/3110/data/10.a b/LibreOJ/3110/data/10.a new file mode 100644 index 00000000..f649fe81 --- /dev/null +++ b/LibreOJ/3110/data/10.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a26ed39c9601331d53898cf9073e7b96185c741f009fcc3e84fbf804d773cbd9 +size 9 diff --git a/LibreOJ/3110/data/11 b/LibreOJ/3110/data/11 new file mode 100644 index 00000000..0531ed4c --- /dev/null +++ b/LibreOJ/3110/data/11 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0dbe47f407ca995a1875521b03fd118ca6e34330fe65f8ea765dae88f7ecdb27 +size 1832952 diff --git a/LibreOJ/3110/data/11.a b/LibreOJ/3110/data/11.a new file mode 100644 index 00000000..9d357c50 --- /dev/null +++ b/LibreOJ/3110/data/11.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6725deb9d49324fb1705e98a4f212491ded5d0e74a5c5d1743c67383f19f6232 +size 9