0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 13:56:26 +00:00

#3110. 「SDOI2019」快速查询

https://loj.ac/s/1603421
This commit is contained in:
Baoshuo Ren 2022-10-12 08:18:13 +08:00
parent 32d290e513
commit b2b875c0eb
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
21 changed files with 157 additions and 0 deletions

97
LibreOJ/3110/3110.cpp Normal file
View File

@ -0,0 +1,97 @@
#include <iostream>
#include <unordered_map>
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<int, int, int> ops[Q];
std::unordered_map<int, int> map;
int get(int x) {
return (static_cast<long long>(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<long long>(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<long long>(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<long long>(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<long long>(value) * n % mod) % mod + mod) % mod;
} else if (op == 3) {
int value = std::get<1>(ops[id]);
mul = (static_cast<long long>(mul) * value % mod + mod) % mod;
add = (static_cast<long long>(add) * value % mod + mod) % mod;
sum = (static_cast<long long>(sum) * value % mod + mod) % mod;
} else if (op == 4) {
int value = std::get<1>(ops[id]);
mul = 1;
add = value;
sum = (static_cast<long long>(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;
}

BIN
LibreOJ/3110/data/02 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/02.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/03 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/03.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/04 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/04.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/05 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/05.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/06 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/06.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/07 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/07.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/08 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/08.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/09 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/09.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/10 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/10.a (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/11 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3110/data/11.a (Stored with Git LFS) Normal file

Binary file not shown.