# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
147673 |
2019-08-30T11:37:20 Z |
forestryks |
Lottery (CEOI18_lot) |
C++14 |
|
951 ms |
12664 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
#define rep(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define all(x) (x).begin(), (x).end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MAXN = 1e4 + 5;
const int MAXQ = 105;
int n, k, m;
int a[MAXN];
vector<int> q[MAXN];
vector<int> v;
int res[MAXN][MAXQ];
int ans[MAXQ][MAXN];
int main() {
FAST_IO;
cin >> n >> k;
rep(i, n) {
cin >> a[i];
}
cin >> m;
rep(i, m) {
int t;
cin >> t;
q[t].push_back(i);
}
rep(i, n + 1) {
if (!q[i].empty()) {
v.push_back(i);
}
}
v.push_back(1e9);
for (int off = 1; off + k <= n; ++off) {
int ptr = 0;
int c = 0;
for (int i = 0; i < k; ++i) {
if (a[i] != a[off + i]) {
c++;
while (v[ptr] < c) {
ptr++;
}
}
}
res[0][ptr]++;
res[off][ptr]++;
for (int i = 1; i + off + k <= n; ++i) {
if (a[i - 1] != a[off + i - 1]) {
c--;
while (ptr > 0 && v[ptr - 1] >= c) {
ptr--;
}
}
if (a[i + k - 1] != a[i + off + k - 1]) {
c++;
while (v[ptr] < c) {
ptr++;
}
}
res[i][ptr]++;
res[i + off][ptr]++;
}
}
rep(i, n) {
for (int j = 1; j < v.size(); ++j) {
res[i][j] += res[i][j - 1];
}
}
int c = 0;
rep(i, n + 1) {
if (q[i].empty()) continue;
for (auto t : q[i]) {
rep(j, n) {
ans[t][j] = res[j][c];
}
}
c++;
}
rep(i, m) {
rep(j, n - k + 1) {
cout << ans[i][j] << ' ';
}
cout << '\n';
}
}
Compilation message
lot.cpp: In function 'int main()':
lot.cpp:75:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 1; j < v.size(); ++j) {
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
2 ms |
632 KB |
Output is correct |
6 |
Correct |
2 ms |
632 KB |
Output is correct |
7 |
Correct |
3 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
764 KB |
Output is correct |
11 |
Correct |
4 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
2 ms |
632 KB |
Output is correct |
6 |
Correct |
2 ms |
632 KB |
Output is correct |
7 |
Correct |
3 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
764 KB |
Output is correct |
11 |
Correct |
4 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
888 KB |
Output is correct |
13 |
Correct |
24 ms |
1556 KB |
Output is correct |
14 |
Correct |
15 ms |
1784 KB |
Output is correct |
15 |
Correct |
11 ms |
1656 KB |
Output is correct |
16 |
Correct |
22 ms |
1784 KB |
Output is correct |
17 |
Correct |
16 ms |
1784 KB |
Output is correct |
18 |
Correct |
16 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
572 ms |
4800 KB |
Output is correct |
2 |
Correct |
776 ms |
4792 KB |
Output is correct |
3 |
Correct |
480 ms |
4856 KB |
Output is correct |
4 |
Correct |
458 ms |
4860 KB |
Output is correct |
5 |
Correct |
135 ms |
4856 KB |
Output is correct |
6 |
Correct |
420 ms |
4856 KB |
Output is correct |
7 |
Correct |
122 ms |
4984 KB |
Output is correct |
8 |
Correct |
219 ms |
4984 KB |
Output is correct |
9 |
Correct |
438 ms |
4856 KB |
Output is correct |
10 |
Correct |
444 ms |
4916 KB |
Output is correct |
11 |
Correct |
25 ms |
1912 KB |
Output is correct |
12 |
Correct |
245 ms |
4432 KB |
Output is correct |
13 |
Correct |
194 ms |
4984 KB |
Output is correct |
14 |
Correct |
196 ms |
4856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
572 ms |
4800 KB |
Output is correct |
2 |
Correct |
776 ms |
4792 KB |
Output is correct |
3 |
Correct |
480 ms |
4856 KB |
Output is correct |
4 |
Correct |
458 ms |
4860 KB |
Output is correct |
5 |
Correct |
135 ms |
4856 KB |
Output is correct |
6 |
Correct |
420 ms |
4856 KB |
Output is correct |
7 |
Correct |
122 ms |
4984 KB |
Output is correct |
8 |
Correct |
219 ms |
4984 KB |
Output is correct |
9 |
Correct |
438 ms |
4856 KB |
Output is correct |
10 |
Correct |
444 ms |
4916 KB |
Output is correct |
11 |
Correct |
25 ms |
1912 KB |
Output is correct |
12 |
Correct |
245 ms |
4432 KB |
Output is correct |
13 |
Correct |
194 ms |
4984 KB |
Output is correct |
14 |
Correct |
196 ms |
4856 KB |
Output is correct |
15 |
Correct |
507 ms |
4856 KB |
Output is correct |
16 |
Correct |
394 ms |
4984 KB |
Output is correct |
17 |
Correct |
485 ms |
4908 KB |
Output is correct |
18 |
Correct |
473 ms |
4856 KB |
Output is correct |
19 |
Correct |
473 ms |
4856 KB |
Output is correct |
20 |
Correct |
451 ms |
4856 KB |
Output is correct |
21 |
Correct |
464 ms |
4856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
2 ms |
632 KB |
Output is correct |
6 |
Correct |
2 ms |
632 KB |
Output is correct |
7 |
Correct |
3 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
764 KB |
Output is correct |
11 |
Correct |
4 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
888 KB |
Output is correct |
13 |
Correct |
24 ms |
1556 KB |
Output is correct |
14 |
Correct |
15 ms |
1784 KB |
Output is correct |
15 |
Correct |
11 ms |
1656 KB |
Output is correct |
16 |
Correct |
22 ms |
1784 KB |
Output is correct |
17 |
Correct |
16 ms |
1784 KB |
Output is correct |
18 |
Correct |
16 ms |
1784 KB |
Output is correct |
19 |
Correct |
572 ms |
4800 KB |
Output is correct |
20 |
Correct |
776 ms |
4792 KB |
Output is correct |
21 |
Correct |
480 ms |
4856 KB |
Output is correct |
22 |
Correct |
458 ms |
4860 KB |
Output is correct |
23 |
Correct |
135 ms |
4856 KB |
Output is correct |
24 |
Correct |
420 ms |
4856 KB |
Output is correct |
25 |
Correct |
122 ms |
4984 KB |
Output is correct |
26 |
Correct |
219 ms |
4984 KB |
Output is correct |
27 |
Correct |
438 ms |
4856 KB |
Output is correct |
28 |
Correct |
444 ms |
4916 KB |
Output is correct |
29 |
Correct |
25 ms |
1912 KB |
Output is correct |
30 |
Correct |
245 ms |
4432 KB |
Output is correct |
31 |
Correct |
194 ms |
4984 KB |
Output is correct |
32 |
Correct |
196 ms |
4856 KB |
Output is correct |
33 |
Correct |
507 ms |
4856 KB |
Output is correct |
34 |
Correct |
394 ms |
4984 KB |
Output is correct |
35 |
Correct |
485 ms |
4908 KB |
Output is correct |
36 |
Correct |
473 ms |
4856 KB |
Output is correct |
37 |
Correct |
473 ms |
4856 KB |
Output is correct |
38 |
Correct |
451 ms |
4856 KB |
Output is correct |
39 |
Correct |
464 ms |
4856 KB |
Output is correct |
40 |
Correct |
878 ms |
6296 KB |
Output is correct |
41 |
Correct |
24 ms |
5624 KB |
Output is correct |
42 |
Correct |
467 ms |
6364 KB |
Output is correct |
43 |
Correct |
467 ms |
6008 KB |
Output is correct |
44 |
Correct |
454 ms |
6264 KB |
Output is correct |
45 |
Correct |
951 ms |
12600 KB |
Output is correct |
46 |
Correct |
37 ms |
9080 KB |
Output is correct |
47 |
Correct |
670 ms |
12664 KB |
Output is correct |
48 |
Correct |
512 ms |
10964 KB |
Output is correct |
49 |
Correct |
506 ms |
11640 KB |
Output is correct |