# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
166300 |
2019-12-01T13:29:28 Z |
Eae02 |
Lottery (CEOI18_lot) |
C++14 |
|
2344 ms |
13048 KB |
#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
using namespace std;
int main() {
int n, l;
cin >> n >> l;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
int q;
cin >> q;
vector<int> queriesK(q);
for (int i = 0; i < q; i++) {
cin >> queriesK[i];
}
vector<int> distinctK = queriesK;
sort(all(distinctK));
distinctK.erase(unique(all(distinctK)), distinctK.end());
vector<vector<int>> sm;
sm.reserve(n);
for (int i = 0; i < n; i++)
sm.emplace_back(distinctK.size() + 1);
vector<int> diffCount(n - l + 1, 0);
auto applyDiff = [&] (int i0) {
#ifdef LOCAL
for (int i = i0 + 1; i + l <= n; i++) {
int d = 0;
for (int j = 0; j < l; j++) {
if (a[i0 + j] != a[i + j])
d++;
}
if (d != diffCount[i]) {
cerr << "Error between " << i0 << " " << i << " got " << diffCount[i] << " exp " << d << "\n";
abort();
}
}
#endif
for (int i = i0 + 1; i + l <= n; i++) {
int kIdx = lower_bound(all(distinctK), diffCount[i]) - distinctK.begin();
sm[i0][kIdx]++;
sm[i][kIdx]++;
}
};
for (int ist = 1; ist + l <= n; ist++) {
for (int j = 0; j < l; j++) {
if (a[j] != a[ist + j])
diffCount[ist]++;
}
}
applyDiff(0);
for (int i0 = 1; i0 + l <= n; i0++) {
for (int i1 = n - l; i1 > i0; i1--) {
diffCount[i1] = diffCount[i1 - 1];
if (a[i0 - 1] != a[i1 - 1])
diffCount[i1]--;
if (a[i0 + l - 1] != a[i1 + l - 1])
diffCount[i1]++;
}
applyDiff(i0);
}
vector<vector<int>> prefixSum(n);
for (int i = 0; i < n; i++) {
prefixSum[i].resize(sm[i].size() + 1, 0);
for (int j = 0; j < sm[i].size(); j++) {
prefixSum[i][j + 1] = prefixSum[i][j] + sm[i][j];
}
}
for (int k : queriesK) {
int kIdx = (lower_bound(all(distinctK), k) - distinctK.begin()) + 1;
for (int i = 0; i < n - l + 1; i++) {
cout << prefixSum[i][kIdx] << " ";
}
cout << "\n";
}
}
Compilation message
lot.cpp: In function 'int main()':
lot.cpp:74:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < sm[i].size(); j++) {
~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
11 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
11 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
34 ms |
636 KB |
Output is correct |
14 |
Correct |
19 ms |
888 KB |
Output is correct |
15 |
Correct |
17 ms |
760 KB |
Output is correct |
16 |
Correct |
29 ms |
1016 KB |
Output is correct |
17 |
Correct |
26 ms |
888 KB |
Output is correct |
18 |
Correct |
26 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
665 ms |
1528 KB |
Output is correct |
2 |
Correct |
747 ms |
1656 KB |
Output is correct |
3 |
Correct |
414 ms |
1564 KB |
Output is correct |
4 |
Correct |
323 ms |
1628 KB |
Output is correct |
5 |
Correct |
135 ms |
1688 KB |
Output is correct |
6 |
Correct |
303 ms |
1656 KB |
Output is correct |
7 |
Correct |
118 ms |
1656 KB |
Output is correct |
8 |
Correct |
178 ms |
1784 KB |
Output is correct |
9 |
Correct |
327 ms |
1628 KB |
Output is correct |
10 |
Correct |
360 ms |
1656 KB |
Output is correct |
11 |
Correct |
21 ms |
760 KB |
Output is correct |
12 |
Correct |
206 ms |
1500 KB |
Output is correct |
13 |
Correct |
183 ms |
1632 KB |
Output is correct |
14 |
Correct |
181 ms |
1596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
665 ms |
1528 KB |
Output is correct |
2 |
Correct |
747 ms |
1656 KB |
Output is correct |
3 |
Correct |
414 ms |
1564 KB |
Output is correct |
4 |
Correct |
323 ms |
1628 KB |
Output is correct |
5 |
Correct |
135 ms |
1688 KB |
Output is correct |
6 |
Correct |
303 ms |
1656 KB |
Output is correct |
7 |
Correct |
118 ms |
1656 KB |
Output is correct |
8 |
Correct |
178 ms |
1784 KB |
Output is correct |
9 |
Correct |
327 ms |
1628 KB |
Output is correct |
10 |
Correct |
360 ms |
1656 KB |
Output is correct |
11 |
Correct |
21 ms |
760 KB |
Output is correct |
12 |
Correct |
206 ms |
1500 KB |
Output is correct |
13 |
Correct |
183 ms |
1632 KB |
Output is correct |
14 |
Correct |
181 ms |
1596 KB |
Output is correct |
15 |
Correct |
694 ms |
1536 KB |
Output is correct |
16 |
Correct |
299 ms |
1656 KB |
Output is correct |
17 |
Correct |
338 ms |
1656 KB |
Output is correct |
18 |
Correct |
316 ms |
1584 KB |
Output is correct |
19 |
Correct |
320 ms |
1608 KB |
Output is correct |
20 |
Correct |
325 ms |
1656 KB |
Output is correct |
21 |
Correct |
333 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
11 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
34 ms |
636 KB |
Output is correct |
14 |
Correct |
19 ms |
888 KB |
Output is correct |
15 |
Correct |
17 ms |
760 KB |
Output is correct |
16 |
Correct |
29 ms |
1016 KB |
Output is correct |
17 |
Correct |
26 ms |
888 KB |
Output is correct |
18 |
Correct |
26 ms |
888 KB |
Output is correct |
19 |
Correct |
665 ms |
1528 KB |
Output is correct |
20 |
Correct |
747 ms |
1656 KB |
Output is correct |
21 |
Correct |
414 ms |
1564 KB |
Output is correct |
22 |
Correct |
323 ms |
1628 KB |
Output is correct |
23 |
Correct |
135 ms |
1688 KB |
Output is correct |
24 |
Correct |
303 ms |
1656 KB |
Output is correct |
25 |
Correct |
118 ms |
1656 KB |
Output is correct |
26 |
Correct |
178 ms |
1784 KB |
Output is correct |
27 |
Correct |
327 ms |
1628 KB |
Output is correct |
28 |
Correct |
360 ms |
1656 KB |
Output is correct |
29 |
Correct |
21 ms |
760 KB |
Output is correct |
30 |
Correct |
206 ms |
1500 KB |
Output is correct |
31 |
Correct |
183 ms |
1632 KB |
Output is correct |
32 |
Correct |
181 ms |
1596 KB |
Output is correct |
33 |
Correct |
694 ms |
1536 KB |
Output is correct |
34 |
Correct |
299 ms |
1656 KB |
Output is correct |
35 |
Correct |
338 ms |
1656 KB |
Output is correct |
36 |
Correct |
316 ms |
1584 KB |
Output is correct |
37 |
Correct |
320 ms |
1608 KB |
Output is correct |
38 |
Correct |
325 ms |
1656 KB |
Output is correct |
39 |
Correct |
333 ms |
1656 KB |
Output is correct |
40 |
Correct |
1465 ms |
3600 KB |
Output is correct |
41 |
Correct |
45 ms |
2936 KB |
Output is correct |
42 |
Correct |
636 ms |
3676 KB |
Output is correct |
43 |
Correct |
580 ms |
3288 KB |
Output is correct |
44 |
Correct |
592 ms |
3448 KB |
Output is correct |
45 |
Correct |
2344 ms |
13048 KB |
Output is correct |
46 |
Correct |
64 ms |
9336 KB |
Output is correct |
47 |
Correct |
1040 ms |
12968 KB |
Output is correct |
48 |
Correct |
1024 ms |
10284 KB |
Output is correct |
49 |
Correct |
921 ms |
10912 KB |
Output is correct |