mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 22:48:48 +00:00
#1709. 【2022.10.31 联考】出题(questions)
https://sjzezoj.com/submission/62647
This commit is contained in:
parent
017a3770b3
commit
5e3a377aa6
71
S2OJ/1709/1709.cpp
Normal file
71
S2OJ/1709/1709.cpp
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
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<int, int, int, int> 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;
|
||||||
|
}
|
BIN
S2OJ/1709/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1709/data/questions9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1709/data/questions9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user