diff --git a/S2OJ/1651/1651.cpp b/S2OJ/1651/1651.cpp new file mode 100644 index 00000000..1ed0a221 --- /dev/null +++ b/S2OJ/1651/1651.cpp @@ -0,0 +1,86 @@ +#include +#include +#include + +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 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; +} diff --git a/S2OJ/1651/data/light1.ans b/S2OJ/1651/data/light1.ans new file mode 100644 index 00000000..a4d53cbc --- /dev/null +++ b/S2OJ/1651/data/light1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:433a167c1a6d18adf6233869c866cea7aa624da0ea5e7466b33707d9be7abae9 +size 1884 diff --git a/S2OJ/1651/data/light1.in b/S2OJ/1651/data/light1.in new file mode 100644 index 00000000..019a3652 --- /dev/null +++ b/S2OJ/1651/data/light1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:213a57cef198495c0b72ab5842a79c87801eafa331eab628587284ebfcc5b7c8 +size 3622 diff --git a/S2OJ/1651/data/light10.ans b/S2OJ/1651/data/light10.ans new file mode 100644 index 00000000..8056065f --- /dev/null +++ b/S2OJ/1651/data/light10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed0e417c1337edb834984d1eb414c9c5f2627ba244fc3e322d95d132076be36f +size 1199979 diff --git a/S2OJ/1651/data/light10.in b/S2OJ/1651/data/light10.in new file mode 100644 index 00000000..dfb2f90d --- /dev/null +++ b/S2OJ/1651/data/light10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b01150ae32982c42fa66f0a5b5af4515bf4f7ee3e6cc3995c80834fbaaeea3a7 +size 1483852 diff --git a/S2OJ/1651/data/light11.ans b/S2OJ/1651/data/light11.ans new file mode 100644 index 00000000..af34b8ed --- /dev/null +++ b/S2OJ/1651/data/light11.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:161e615d87207998ee55db506a871e1a7876ae129b87239b139305ce596747a1 +size 287708 diff --git a/S2OJ/1651/data/light11.in b/S2OJ/1651/data/light11.in new file mode 100644 index 00000000..85c62a69 --- /dev/null +++ b/S2OJ/1651/data/light11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:949096c1010ff309b9846063d3e6d98e724189e837ce3e11f3e542cea573d6d1 +size 586726 diff --git a/S2OJ/1651/data/light12.ans b/S2OJ/1651/data/light12.ans new file mode 100644 index 00000000..f86a6528 --- /dev/null +++ b/S2OJ/1651/data/light12.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a1364c61100278f967b8f7720a4422da9547777d033bb2ea980e2f80fbf8d29 +size 287727 diff --git a/S2OJ/1651/data/light12.in b/S2OJ/1651/data/light12.in new file mode 100644 index 00000000..30425c95 --- /dev/null +++ b/S2OJ/1651/data/light12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:903deb038284da4adc5675b26afcef4e7e19954b4c32b5511c36926b0d588441 +size 585717 diff --git a/S2OJ/1651/data/light13.ans b/S2OJ/1651/data/light13.ans new file mode 100644 index 00000000..f36a2664 --- /dev/null +++ b/S2OJ/1651/data/light13.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2da49e96f1a628db27d559a5455dd5f6c03b9cba310f3830839a2764cee39bc6 +size 287349 diff --git a/S2OJ/1651/data/light13.in b/S2OJ/1651/data/light13.in new file mode 100644 index 00000000..d6a67064 --- /dev/null +++ b/S2OJ/1651/data/light13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7097888a255b870a1a613e146f0fc2a7e57fc45b6447d53a74ba132a6ddcfce +size 546503 diff --git a/S2OJ/1651/data/light14.ans b/S2OJ/1651/data/light14.ans new file mode 100644 index 00000000..f2c187b7 --- /dev/null +++ b/S2OJ/1651/data/light14.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e44be3d6be2c9b2e1900089ea3069e8bcb8ff6ffe7034ec4186b81379e6db9f7 +size 287425 diff --git a/S2OJ/1651/data/light14.in b/S2OJ/1651/data/light14.in new file mode 100644 index 00000000..31930332 --- /dev/null +++ b/S2OJ/1651/data/light14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1de59649c7807bdc98cfb2f4e8e0b9d6d475fe70129c5e25690a53dac72bbb5d +size 586216 diff --git a/S2OJ/1651/data/light15.ans b/S2OJ/1651/data/light15.ans new file mode 100644 index 00000000..85b9eddd --- /dev/null +++ b/S2OJ/1651/data/light15.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e95c49a0376009e4ffe7b1e3157eece782f7eb23683f37d7141e0a4ba00a6f5e +size 287632 diff --git a/S2OJ/1651/data/light15.in b/S2OJ/1651/data/light15.in new file mode 100644 index 00000000..5a4c70c6 --- /dev/null +++ b/S2OJ/1651/data/light15.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7766170d2117201c7e9a4168a0e949d4c88177d16731092bc3a2ac3f379315c +size 548095 diff --git a/S2OJ/1651/data/light16.ans b/S2OJ/1651/data/light16.ans new file mode 100644 index 00000000..8f04a1e1 --- /dev/null +++ b/S2OJ/1651/data/light16.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a4c576ab0fd0a9282779dc9743a030f5ae7bd844cdc4617da6c17355b951458 +size 287336 diff --git a/S2OJ/1651/data/light16.in b/S2OJ/1651/data/light16.in new file mode 100644 index 00000000..fdfb8a63 --- /dev/null +++ b/S2OJ/1651/data/light16.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:44b1581496483e252c286b71915e8310fd03adaf53136e81896d63728207ba2e +size 586350 diff --git a/S2OJ/1651/data/light17.ans b/S2OJ/1651/data/light17.ans new file mode 100644 index 00000000..b26d42e4 --- /dev/null +++ b/S2OJ/1651/data/light17.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:888227996b8e184a7da79f3429adc98d00ae1c42b7992c360d196f3b0916cd9f +size 1190753 diff --git a/S2OJ/1651/data/light17.in b/S2OJ/1651/data/light17.in new file mode 100644 index 00000000..a96cdf6c --- /dev/null +++ b/S2OJ/1651/data/light17.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:399dae778eff0e06c34dca20ec46abb97c63c942384ac42ba51eec487fea649a +size 2626852 diff --git a/S2OJ/1651/data/light18.ans b/S2OJ/1651/data/light18.ans new file mode 100644 index 00000000..3df15601 --- /dev/null +++ b/S2OJ/1651/data/light18.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6db24cc0c5e6cc402d8cb74f19fc09402e250de0fdf165543f15135f60a0da6b +size 1189713 diff --git a/S2OJ/1651/data/light18.in b/S2OJ/1651/data/light18.in new file mode 100644 index 00000000..9a1770d6 --- /dev/null +++ b/S2OJ/1651/data/light18.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbbede7f9bcd90e8cd348063276ebdd40cda0663092357286f8c267d08171887 +size 2548234 diff --git a/S2OJ/1651/data/light19.ans b/S2OJ/1651/data/light19.ans new file mode 100644 index 00000000..c0fcba78 --- /dev/null +++ b/S2OJ/1651/data/light19.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15b62b677dedba6845f742534eacee73178c60b289cb1c847cbe4340344d5a86 +size 1190149 diff --git a/S2OJ/1651/data/light19.in b/S2OJ/1651/data/light19.in new file mode 100644 index 00000000..56412d90 --- /dev/null +++ b/S2OJ/1651/data/light19.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4609cc325f0161318cdcc5e65b7655f8a4d5abecc088b05f2028707d60e03b25 +size 2635061 diff --git a/S2OJ/1651/data/light2.ans b/S2OJ/1651/data/light2.ans new file mode 100644 index 00000000..5e438a58 --- /dev/null +++ b/S2OJ/1651/data/light2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81115ecf94902c79a29631bd0cbd79486b29a157cb312d770c6e2aedb382c3c7 +size 1886 diff --git a/S2OJ/1651/data/light2.in b/S2OJ/1651/data/light2.in new file mode 100644 index 00000000..e714eaad --- /dev/null +++ b/S2OJ/1651/data/light2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d301f1b2181a9d982b9cbc22236f7b8e3bc692fdde1539df47e7d19ee4d92e0d +size 3782 diff --git a/S2OJ/1651/data/light20.ans b/S2OJ/1651/data/light20.ans new file mode 100644 index 00000000..6e05964c --- /dev/null +++ b/S2OJ/1651/data/light20.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e6e3e33c03a572da8f0b8ca9191c539536b0a67a08c51d6cd6291eb4aabf21e +size 1189434 diff --git a/S2OJ/1651/data/light20.in b/S2OJ/1651/data/light20.in new file mode 100644 index 00000000..2920dbb0 --- /dev/null +++ b/S2OJ/1651/data/light20.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca7deaffe14ef614fea41e9ae313ce73e04512858b18cad39bb2708a26667045 +size 2629887 diff --git a/S2OJ/1651/data/light3.ans b/S2OJ/1651/data/light3.ans new file mode 100644 index 00000000..d21abb6d --- /dev/null +++ b/S2OJ/1651/data/light3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02ab57521b615b9489071c6b45d95bdd35d0217afe8fe5c6a75b017ca8f8b2fc +size 1857 diff --git a/S2OJ/1651/data/light3.in b/S2OJ/1651/data/light3.in new file mode 100644 index 00000000..e18e42ff --- /dev/null +++ b/S2OJ/1651/data/light3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18ea99c16bf76c2522937e4e4125eeb55cea27770af691504e05835c0bca9e18 +size 3969 diff --git a/S2OJ/1651/data/light4.ans b/S2OJ/1651/data/light4.ans new file mode 100644 index 00000000..8458940e --- /dev/null +++ b/S2OJ/1651/data/light4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:010a7b4b37910c08b37250bb2049bd5e2dca877ff46f1a24192dce1cdf748b83 +size 1884 diff --git a/S2OJ/1651/data/light4.in b/S2OJ/1651/data/light4.in new file mode 100644 index 00000000..bd670bd9 --- /dev/null +++ b/S2OJ/1651/data/light4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac2f7a5c985fcba1192d2d8f03cc17b84d9e0a33b0a9f6985ffa9f6364960a9a +size 3711 diff --git a/S2OJ/1651/data/light5.ans b/S2OJ/1651/data/light5.ans new file mode 100644 index 00000000..5be38165 --- /dev/null +++ b/S2OJ/1651/data/light5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddf4f9ab305ef93665acc54c91800b1498621b0ebe6254efaaf7a0199b54bad7 +size 23733 diff --git a/S2OJ/1651/data/light5.in b/S2OJ/1651/data/light5.in new file mode 100644 index 00000000..e849c3a2 --- /dev/null +++ b/S2OJ/1651/data/light5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:022740f924706240cb49432a48c2afe865c094c013ab5fb8db690b0b7f121861 +size 46793 diff --git a/S2OJ/1651/data/light6.ans b/S2OJ/1651/data/light6.ans new file mode 100644 index 00000000..aab9e840 --- /dev/null +++ b/S2OJ/1651/data/light6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ef51e64680dbf6198fe98bce6e706729cafc999dd8bddc3e869f238bdc1c0cb +size 23737 diff --git a/S2OJ/1651/data/light6.in b/S2OJ/1651/data/light6.in new file mode 100644 index 00000000..9a4023fa --- /dev/null +++ b/S2OJ/1651/data/light6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c269bd6341903891e50e836bcf4bf965620e7f41992d99db58eaa954c1c0d5a +size 47655 diff --git a/S2OJ/1651/data/light7.ans b/S2OJ/1651/data/light7.ans new file mode 100644 index 00000000..e569ef22 --- /dev/null +++ b/S2OJ/1651/data/light7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ae7741d35f9353d4c7d9c73ec01dad30e881c75bbffdc95a6fb99e7b33b905f +size 23877 diff --git a/S2OJ/1651/data/light7.in b/S2OJ/1651/data/light7.in new file mode 100644 index 00000000..e0caac4e --- /dev/null +++ b/S2OJ/1651/data/light7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2859dc623734070e79465e02659961bd76e03acb024a8274660428e5569be716 +size 48271 diff --git a/S2OJ/1651/data/light8.ans b/S2OJ/1651/data/light8.ans new file mode 100644 index 00000000..ee7a10fb --- /dev/null +++ b/S2OJ/1651/data/light8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a88ff6177105e515a281182350589409fe53dd55437f51165ba14e6aabe492e2 +size 1199986 diff --git a/S2OJ/1651/data/light8.in b/S2OJ/1651/data/light8.in new file mode 100644 index 00000000..70bcbb8e --- /dev/null +++ b/S2OJ/1651/data/light8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88f7bfc52d04c480974a499679ed81fdcc82a59a7345cea9c49b8de4ead29ea4 +size 1566053 diff --git a/S2OJ/1651/data/light9.ans b/S2OJ/1651/data/light9.ans new file mode 100644 index 00000000..0a7fa698 --- /dev/null +++ b/S2OJ/1651/data/light9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32ce47c421b1c064c9d4eabfcacf9b2978d6de249e2502478d1bba05c7e13f39 +size 1199983 diff --git a/S2OJ/1651/data/light9.in b/S2OJ/1651/data/light9.in new file mode 100644 index 00000000..cbd42fe8 --- /dev/null +++ b/S2OJ/1651/data/light9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1638ef73a39bc0bc85e8a227c23a378d57a242bb72752ed850495dc04d39f335 +size 1560971 diff --git a/S2OJ/1651/data/problem.conf b/S2OJ/1651/data/problem.conf new file mode 100644 index 00000000..8d809117 --- /dev/null +++ b/S2OJ/1651/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b93fb6922c5f126c18a4464a09d6288af5944dd780829a59208b841e81ac6cb +size 179