mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 18:28:47 +00:00
parent
86edd7a03e
commit
285997f22a
86
S2OJ/1651/1651.cpp
Normal file
86
S2OJ/1651/1651.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 2e5 + 5;
|
||||
|
||||
int n, q, k, b, l[N], id[N], w[N], cnt[505][505], t[N], sum, res;
|
||||
std::vector<int> pos[N], large;
|
||||
bool st[N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> q >> k;
|
||||
|
||||
b = std::ceil(std::sqrt(n));
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> l[i];
|
||||
|
||||
pos[l[i]].emplace_back(i);
|
||||
|
||||
if (l[i] == l[i - 1]) w[l[i]]++;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
if (pos[i].size() > b) {
|
||||
large.emplace_back(i);
|
||||
id[i] = large.size();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < large.size(); i++) {
|
||||
for (int x : pos[large[i]]) {
|
||||
if (id[l[x - 1]]) {
|
||||
cnt[i + 1][id[l[x - 1]]]++;
|
||||
}
|
||||
|
||||
if (id[l[x + 1]]) {
|
||||
cnt[i + 1][id[l[x + 1]]]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (q--) {
|
||||
int x;
|
||||
|
||||
cin >> x;
|
||||
|
||||
st[x] ^= 1;
|
||||
|
||||
int o = st[x] ? 1 : -1;
|
||||
|
||||
sum += o * pos[x].size();
|
||||
res += o * w[x];
|
||||
|
||||
if (id[x]) {
|
||||
for (int i = 1; i <= large.size(); i++) {
|
||||
if (i == id[x]) continue;
|
||||
|
||||
if (st[large[i - 1]]) {
|
||||
res += o * cnt[id[x]][i];
|
||||
}
|
||||
}
|
||||
|
||||
res += o * t[x];
|
||||
} else {
|
||||
for (int y : pos[x]) {
|
||||
if (st[l[y - 1]] && l[y - 1] != l[y]) res += o;
|
||||
if (st[l[y + 1]] && l[y + 1] != l[y]) res += o;
|
||||
|
||||
if (id[l[y - 1]] && l[y - 1] != l[y]) t[l[y - 1]] += o;
|
||||
if (id[l[y + 1]] && l[y + 1] != l[y]) t[l[y + 1]] += o;
|
||||
}
|
||||
}
|
||||
|
||||
cout << sum - res << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1651/data/light1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light10.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light11.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light11.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light12.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light12.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light13.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light13.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light14.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light14.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light14.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light15.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light15.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light15.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light16.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light16.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light16.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light17.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light17.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light17.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light18.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light18.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light18.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light19.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light19.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light19.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light20.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light20.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light20.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light3.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light4.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light5.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light6.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light7.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light8.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light9.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/light9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/light9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1651/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1651/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user