From 5e3a377aa6880a96ce4b18153db6b63be258a82a Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Tue, 1 Nov 2022 07:18:36 +0800 Subject: [PATCH] =?UTF-8?q?#1709.=20=E3=80=902022.10.31=20=E8=81=94?= =?UTF-8?q?=E8=80=83=E3=80=91=E5=87=BA=E9=A2=98=EF=BC=88questions=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/62647 --- S2OJ/1709/1709.cpp | 71 ++++++++++++++++++++++++++++++++++ S2OJ/1709/data/problem.conf | 3 ++ S2OJ/1709/data/questions1.in | 3 ++ S2OJ/1709/data/questions1.out | 3 ++ S2OJ/1709/data/questions10.in | 3 ++ S2OJ/1709/data/questions10.out | 3 ++ S2OJ/1709/data/questions2.in | 3 ++ S2OJ/1709/data/questions2.out | 3 ++ S2OJ/1709/data/questions3.in | 3 ++ S2OJ/1709/data/questions3.out | 3 ++ S2OJ/1709/data/questions4.in | 3 ++ S2OJ/1709/data/questions4.out | 3 ++ S2OJ/1709/data/questions5.in | 3 ++ S2OJ/1709/data/questions5.out | 3 ++ S2OJ/1709/data/questions6.in | 3 ++ S2OJ/1709/data/questions6.out | 3 ++ S2OJ/1709/data/questions7.in | 3 ++ S2OJ/1709/data/questions7.out | 3 ++ S2OJ/1709/data/questions8.in | 3 ++ S2OJ/1709/data/questions8.out | 3 ++ S2OJ/1709/data/questions9.in | 3 ++ S2OJ/1709/data/questions9.out | 3 ++ 22 files changed, 134 insertions(+) create mode 100644 S2OJ/1709/1709.cpp create mode 100644 S2OJ/1709/data/problem.conf create mode 100644 S2OJ/1709/data/questions1.in create mode 100644 S2OJ/1709/data/questions1.out create mode 100644 S2OJ/1709/data/questions10.in create mode 100644 S2OJ/1709/data/questions10.out create mode 100644 S2OJ/1709/data/questions2.in create mode 100644 S2OJ/1709/data/questions2.out create mode 100644 S2OJ/1709/data/questions3.in create mode 100644 S2OJ/1709/data/questions3.out create mode 100644 S2OJ/1709/data/questions4.in create mode 100644 S2OJ/1709/data/questions4.out create mode 100644 S2OJ/1709/data/questions5.in create mode 100644 S2OJ/1709/data/questions5.out create mode 100644 S2OJ/1709/data/questions6.in create mode 100644 S2OJ/1709/data/questions6.out create mode 100644 S2OJ/1709/data/questions7.in create mode 100644 S2OJ/1709/data/questions7.out create mode 100644 S2OJ/1709/data/questions8.in create mode 100644 S2OJ/1709/data/questions8.out create mode 100644 S2OJ/1709/data/questions9.in create mode 100644 S2OJ/1709/data/questions9.out diff --git a/S2OJ/1709/1709.cpp b/S2OJ/1709/1709.cpp new file mode 100644 index 00000000..be9de5a1 --- /dev/null +++ b/S2OJ/1709/1709.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2e5 + 5; + +int n, q, t, a[N], cnt[N], cnt2[N], ans[N]; +std::tuple queries[N]; + +void add(int x) { + cnt2[++cnt[x]]++; +} + +void del(int x) { + cnt2[cnt[x]--]--; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + cin >> q; + + for (int i = 1; i <= q; i++) { + cin >> std::get<1>(queries[i]) >> std::get<2>(queries[i]) >> std::get<3>(queries[i]); + std::get<0>(queries[i]) = i; + } + + t = std::sqrt(q); + std::sort(queries + 1, queries + 1 + q, [&](auto a, auto b) -> bool { + int p = std::get<1>(a) / t, + q = std::get<1>(b) / t; + + return p == q + ? (p & 1) + ? std::get<2>(a) < std::get<2>(b) + : std::get<2>(a) > std::get<2>(b) + : p < q; + }); + + cnt2[0] = n; + for (int _ = 1, i = 0, j = 1; _ <= q; _++) { + int id, l, r, k; + + std::tie(id, l, r, k) = queries[_]; + + while (i < r) add(a[++i]); + while (i > r) del(a[i--]); + while (j > l) add(a[--j]); + while (j < l) del(a[j++]); + + ans[id] = cnt2[k]; + } + + for (int i = 1; i <= q; i++) { + cout << ans[i] << endl; + } + + return 0; +} diff --git a/S2OJ/1709/data/problem.conf b/S2OJ/1709/data/problem.conf new file mode 100644 index 00000000..827a5050 --- /dev/null +++ b/S2OJ/1709/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab256cbdd7c11e97b61ed000f483ea527bc8620ac3bfa2cfda7b9f4af9dc5ed7 +size 187 diff --git a/S2OJ/1709/data/questions1.in b/S2OJ/1709/data/questions1.in new file mode 100644 index 00000000..85a72f2c --- /dev/null +++ b/S2OJ/1709/data/questions1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c56154876db3dfb1b0daaea6c0912c820cd2c0468bf0b4a8cb6879fbb6fa74c +size 82126 diff --git a/S2OJ/1709/data/questions1.out b/S2OJ/1709/data/questions1.out new file mode 100644 index 00000000..0b285c47 --- /dev/null +++ b/S2OJ/1709/data/questions1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f28ea4f695ae179526a89381fda75361e61dae96b8a609b6de26785e044c1be9 +size 9407 diff --git a/S2OJ/1709/data/questions10.in b/S2OJ/1709/data/questions10.in new file mode 100644 index 00000000..70c7fc13 --- /dev/null +++ b/S2OJ/1709/data/questions10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e8c0a3f1c3095066dc0cabb175d87101def2e5c88f906be1a86adcd1345cf06 +size 4932115 diff --git a/S2OJ/1709/data/questions10.out b/S2OJ/1709/data/questions10.out new file mode 100644 index 00000000..88910d22 --- /dev/null +++ b/S2OJ/1709/data/questions10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49910e2f978b063a8acc8c0efff0063bcd59aa971327a21a3fce17a45bc7524e +size 399601 diff --git a/S2OJ/1709/data/questions2.in b/S2OJ/1709/data/questions2.in new file mode 100644 index 00000000..8289a544 --- /dev/null +++ b/S2OJ/1709/data/questions2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1880aef764cb2ee253dc72525f8b4e0acfb4032077229c67e42bb80cc4bc2f4e +size 73052 diff --git a/S2OJ/1709/data/questions2.out b/S2OJ/1709/data/questions2.out new file mode 100644 index 00000000..6c04fe88 --- /dev/null +++ b/S2OJ/1709/data/questions2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c49e900332b701c11f291a1ae3dd5371474cc4922ed477a1a4872550f9a9bcb7 +size 8850 diff --git a/S2OJ/1709/data/questions3.in b/S2OJ/1709/data/questions3.in new file mode 100644 index 00000000..1a9620e3 --- /dev/null +++ b/S2OJ/1709/data/questions3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54a5394988e0aa35953d9473f0bb7b222ff67f22a889eae95d55fce7830c3435 +size 647354 diff --git a/S2OJ/1709/data/questions3.out b/S2OJ/1709/data/questions3.out new file mode 100644 index 00000000..2dee9a46 --- /dev/null +++ b/S2OJ/1709/data/questions3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd5b983e960027c003eedebf81078f1f74590d05b4157081571912bb302dc81e +size 59095 diff --git a/S2OJ/1709/data/questions4.in b/S2OJ/1709/data/questions4.in new file mode 100644 index 00000000..d2b736be --- /dev/null +++ b/S2OJ/1709/data/questions4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:453f640f2ec9f1c8fe38dcc396932f0ed6ecc65a2c2671581f619dfa8be7123d +size 649992 diff --git a/S2OJ/1709/data/questions4.out b/S2OJ/1709/data/questions4.out new file mode 100644 index 00000000..a1de8664 --- /dev/null +++ b/S2OJ/1709/data/questions4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a1cd7e4c51128a04b5598dd185f7d347c0092a0208ec3547724561ee83a5259 +size 58753 diff --git a/S2OJ/1709/data/questions5.in b/S2OJ/1709/data/questions5.in new file mode 100644 index 00000000..440b5b7d --- /dev/null +++ b/S2OJ/1709/data/questions5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c84a944a63b3fb45ee25df90d9f09b7a1ac963f920f8bc8f27e4bb7c81bc8c1 +size 651063 diff --git a/S2OJ/1709/data/questions5.out b/S2OJ/1709/data/questions5.out new file mode 100644 index 00000000..b35a7891 --- /dev/null +++ b/S2OJ/1709/data/questions5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96f3870a672d13fe568a058d63c795e7ac392473558be48fc09bdbabd5909b05 +size 59703 diff --git a/S2OJ/1709/data/questions6.in b/S2OJ/1709/data/questions6.in new file mode 100644 index 00000000..4cfb0eac --- /dev/null +++ b/S2OJ/1709/data/questions6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c593117833987e9da89955e9ee46e67307cbe986a0eb2850b01d54ac55e07c1a +size 4921800 diff --git a/S2OJ/1709/data/questions6.out b/S2OJ/1709/data/questions6.out new file mode 100644 index 00000000..d1e09e3b --- /dev/null +++ b/S2OJ/1709/data/questions6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b8d64f140adff13372f64462d5140735e72bbbcb1aa1f2c653e28d68d51c78a +size 398856 diff --git a/S2OJ/1709/data/questions7.in b/S2OJ/1709/data/questions7.in new file mode 100644 index 00000000..b17ac824 --- /dev/null +++ b/S2OJ/1709/data/questions7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffac85be6949615a14175c8fea5339431269e9db590209ff93e7b1d8bd619080 +size 4112678 diff --git a/S2OJ/1709/data/questions7.out b/S2OJ/1709/data/questions7.out new file mode 100644 index 00000000..f3f08794 --- /dev/null +++ b/S2OJ/1709/data/questions7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4624a7c9834ae78239cf65a5c1c5f537237e21d0dc38e0af3dd115925996a8c +size 575753 diff --git a/S2OJ/1709/data/questions8.in b/S2OJ/1709/data/questions8.in new file mode 100644 index 00000000..5caa4b1e --- /dev/null +++ b/S2OJ/1709/data/questions8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e37d4b7f13bc262c49231504c1546e921dba5feb5354c03ed48e76841b74f0c1 +size 4506047 diff --git a/S2OJ/1709/data/questions8.out b/S2OJ/1709/data/questions8.out new file mode 100644 index 00000000..228b9139 --- /dev/null +++ b/S2OJ/1709/data/questions8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e80e8a8249520285efb17837222f72e3bff7df11c271bd9c4e3a48ca8475ef6 +size 411685 diff --git a/S2OJ/1709/data/questions9.in b/S2OJ/1709/data/questions9.in new file mode 100644 index 00000000..c87f25a9 --- /dev/null +++ b/S2OJ/1709/data/questions9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58ffef514dceacf31237548aeeea2598a27fc0f1a2b681b8ecfb152e26a8985f +size 4105689 diff --git a/S2OJ/1709/data/questions9.out b/S2OJ/1709/data/questions9.out new file mode 100644 index 00000000..546023fa --- /dev/null +++ b/S2OJ/1709/data/questions9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43986f99c445d6c36bf2ca75aae07110b994b97ef1b0f589381191361605f973 +size 575279