# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
704656 |
2023-03-02T15:02:49 Z |
Cyanmond |
Lottery (CEOI18_lot) |
C++17 |
|
1648 ms |
27596 KB |
#include <bits/stdc++.h>
constexpr int B = 1300;
int main() {
int N, L;
std::cin >> N >> L;
const int U = N - L + 1;
std::vector<int> A(N);
for (auto &e : A) {
std::cin >> e;
}
int Q;
std::cin >> Q;
std::vector<std::pair<int, int>> K(Q);
for (int i = 0; i < Q; ++i) {
std::cin >> K[i].first;
K[i].second = i;
}
std::sort(K.begin(), K.end());
std::vector<std::vector<short>> addVal(Q + 1, std::vector<short>(U));
std::vector<int> level(L + 1);
for (int i = 0; i <= L; ++i) {
int c = 0;
while (c != Q and K[c].first < i) {
++c;
}
level[i] = c;
}
for (int l = 0; l < U; l += B) {
const int r = std::min(l + B, U);
const int lw = r - l;
const int V = (int)A.size() - L + 1;
const int T = std::min(lw, V);
if (T <= 0) {
break;
}
std::vector<std::vector<short>> countSim(T, std::vector<short>(V, 0));
for (int w = 1; w < V; ++w) {
std::vector<int> ids;
for (int i = 0; i < std::min((int)A.size() - w, T + L - 1); ++i) {
if (A[i] == A[i + w]) {
ids.push_back(i);
}
}
auto add = [&](int a, int b) {
int x = std::max(0, -a);
if (a + x < T and a + w + x < V) --countSim[a + x][a + w + x];
if (b < T and b + w < V) ++countSim[b][b + w];
};
for (const int i : ids) {
add(i - L + 1, i + 1);
}
}
for (int i = 0; i < T; ++i) {
for (int j = 0; j < V; ++j) {
if (i != 0 and j != 0) {
countSim[i][j] += countSim[i - 1][j - 1];
}
}
}
for (int i = 0; i < T; ++i) {
for (int j = i + 1; j < V; ++j) {
++addVal[level[countSim[i][j] + L]][i + l];
++addVal[level[countSim[i][j] + L]][j + l];
}
}
A.erase(A.begin(), A.begin() + lw);
}
std::vector<std::vector<short>> answer(Q, std::vector<short>(N));
std::vector<short> nowData(U, 0);
for (int i = 0; i < Q; ++i) {
for (int j = 0; j < U; ++j) {
nowData[j] += addVal[i][j];
}
answer[K[i].second] = nowData;
}
for (const auto &vec : answer) {
for (int i = 0; i < U; ++i) {
std::cout << vec[i] << (i == U - 1 ? '\n' : ' ');
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
53 ms |
5460 KB |
Output is correct |
14 |
Correct |
24 ms |
3796 KB |
Output is correct |
15 |
Correct |
19 ms |
3820 KB |
Output is correct |
16 |
Correct |
43 ms |
4952 KB |
Output is correct |
17 |
Correct |
37 ms |
4684 KB |
Output is correct |
18 |
Correct |
26 ms |
4692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1566 ms |
25904 KB |
Output is correct |
2 |
Correct |
1495 ms |
25880 KB |
Output is correct |
3 |
Correct |
1135 ms |
25932 KB |
Output is correct |
4 |
Correct |
1018 ms |
25428 KB |
Output is correct |
5 |
Correct |
694 ms |
13232 KB |
Output is correct |
6 |
Correct |
964 ms |
24204 KB |
Output is correct |
7 |
Correct |
976 ms |
13288 KB |
Output is correct |
8 |
Correct |
1438 ms |
18388 KB |
Output is correct |
9 |
Correct |
1077 ms |
25064 KB |
Output is correct |
10 |
Correct |
1020 ms |
25472 KB |
Output is correct |
11 |
Correct |
74 ms |
5332 KB |
Output is correct |
12 |
Correct |
698 ms |
18188 KB |
Output is correct |
13 |
Correct |
696 ms |
15572 KB |
Output is correct |
14 |
Correct |
787 ms |
15572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1566 ms |
25904 KB |
Output is correct |
2 |
Correct |
1495 ms |
25880 KB |
Output is correct |
3 |
Correct |
1135 ms |
25932 KB |
Output is correct |
4 |
Correct |
1018 ms |
25428 KB |
Output is correct |
5 |
Correct |
694 ms |
13232 KB |
Output is correct |
6 |
Correct |
964 ms |
24204 KB |
Output is correct |
7 |
Correct |
976 ms |
13288 KB |
Output is correct |
8 |
Correct |
1438 ms |
18388 KB |
Output is correct |
9 |
Correct |
1077 ms |
25064 KB |
Output is correct |
10 |
Correct |
1020 ms |
25472 KB |
Output is correct |
11 |
Correct |
74 ms |
5332 KB |
Output is correct |
12 |
Correct |
698 ms |
18188 KB |
Output is correct |
13 |
Correct |
696 ms |
15572 KB |
Output is correct |
14 |
Correct |
787 ms |
15572 KB |
Output is correct |
15 |
Correct |
1166 ms |
25056 KB |
Output is correct |
16 |
Correct |
919 ms |
23380 KB |
Output is correct |
17 |
Correct |
1055 ms |
25940 KB |
Output is correct |
18 |
Correct |
1008 ms |
25700 KB |
Output is correct |
19 |
Correct |
991 ms |
25684 KB |
Output is correct |
20 |
Correct |
855 ms |
25744 KB |
Output is correct |
21 |
Correct |
1039 ms |
25740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
53 ms |
5460 KB |
Output is correct |
14 |
Correct |
24 ms |
3796 KB |
Output is correct |
15 |
Correct |
19 ms |
3820 KB |
Output is correct |
16 |
Correct |
43 ms |
4952 KB |
Output is correct |
17 |
Correct |
37 ms |
4684 KB |
Output is correct |
18 |
Correct |
26 ms |
4692 KB |
Output is correct |
19 |
Correct |
1566 ms |
25904 KB |
Output is correct |
20 |
Correct |
1495 ms |
25880 KB |
Output is correct |
21 |
Correct |
1135 ms |
25932 KB |
Output is correct |
22 |
Correct |
1018 ms |
25428 KB |
Output is correct |
23 |
Correct |
694 ms |
13232 KB |
Output is correct |
24 |
Correct |
964 ms |
24204 KB |
Output is correct |
25 |
Correct |
976 ms |
13288 KB |
Output is correct |
26 |
Correct |
1438 ms |
18388 KB |
Output is correct |
27 |
Correct |
1077 ms |
25064 KB |
Output is correct |
28 |
Correct |
1020 ms |
25472 KB |
Output is correct |
29 |
Correct |
74 ms |
5332 KB |
Output is correct |
30 |
Correct |
698 ms |
18188 KB |
Output is correct |
31 |
Correct |
696 ms |
15572 KB |
Output is correct |
32 |
Correct |
787 ms |
15572 KB |
Output is correct |
33 |
Correct |
1166 ms |
25056 KB |
Output is correct |
34 |
Correct |
919 ms |
23380 KB |
Output is correct |
35 |
Correct |
1055 ms |
25940 KB |
Output is correct |
36 |
Correct |
1008 ms |
25700 KB |
Output is correct |
37 |
Correct |
991 ms |
25684 KB |
Output is correct |
38 |
Correct |
855 ms |
25744 KB |
Output is correct |
39 |
Correct |
1039 ms |
25740 KB |
Output is correct |
40 |
Correct |
1440 ms |
26032 KB |
Output is correct |
41 |
Correct |
53 ms |
2612 KB |
Output is correct |
42 |
Correct |
1054 ms |
25980 KB |
Output is correct |
43 |
Correct |
835 ms |
25224 KB |
Output is correct |
44 |
Correct |
1006 ms |
25172 KB |
Output is correct |
45 |
Correct |
1648 ms |
27596 KB |
Output is correct |
46 |
Correct |
52 ms |
3016 KB |
Output is correct |
47 |
Correct |
1165 ms |
27536 KB |
Output is correct |
48 |
Correct |
1069 ms |
26720 KB |
Output is correct |
49 |
Correct |
1131 ms |
26708 KB |
Output is correct |