# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
719206 |
2023-04-05T16:15:03 Z |
stevancv |
Lottery (CEOI18_lot) |
C++14 |
|
476 ms |
8304 KB |
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e4 + 2;
const int M = 100 + 2;
const int inf = 1e9;
int a[N], b[M], dp[2][N], ans[M][N], cnt[N], n, l, q, m;
void Solve(int j) {
int t = j & 1;
for (int i = 0; i <= l; i++) cnt[i] = 0;
for (int i = 0; i < m; i++) if (i != j) cnt[dp[t][i]]++;
for (int i = 1; i <= l; i++) cnt[i] += cnt[i - 1];
for (int i = 0; i < q; i++) ans[i][j] = cnt[b[i]];
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> l;
m = n - l + 1;
for (int i = 0; i < n; i++) cin >> a[i];
cin >> q;
for (int i = 0; i < q; i++) cin >> b[i];
for (int i = 0; i < m; i++) for (int j = 0; j < l; j++) dp[0][i] += a[j] != a[i + j];
Solve(0);
for (int i = 1; i < m; i++) {
int t = i & 1;
for (int j = 0; j < m; j++) dp[t][j] = 0;
for (int j = 0; j < l; j++) dp[t][0] += a[i + j] != a[j];
for (int j = 1; j < m; j++) {
dp[t][j] = dp[1 - t][j - 1];
dp[t][j] += (a[i + l - 1] != a[j + l - 1]) - (a[i - 1] != a[j - 1]);
}
Solve(i);
}
for (int i = 0; i < q; i++) {
for (int j = 0; j < m; j++) cout << ans[i][j] << sp;
cout << en;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
444 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 |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
444 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
18 ms |
424 KB |
Output is correct |
14 |
Correct |
14 ms |
628 KB |
Output is correct |
15 |
Correct |
13 ms |
468 KB |
Output is correct |
16 |
Correct |
17 ms |
652 KB |
Output is correct |
17 |
Correct |
16 ms |
588 KB |
Output is correct |
18 |
Correct |
20 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
368 ms |
712 KB |
Output is correct |
2 |
Correct |
428 ms |
488 KB |
Output is correct |
3 |
Correct |
411 ms |
484 KB |
Output is correct |
4 |
Correct |
384 ms |
552 KB |
Output is correct |
5 |
Correct |
206 ms |
588 KB |
Output is correct |
6 |
Correct |
371 ms |
568 KB |
Output is correct |
7 |
Correct |
201 ms |
484 KB |
Output is correct |
8 |
Correct |
285 ms |
532 KB |
Output is correct |
9 |
Correct |
386 ms |
588 KB |
Output is correct |
10 |
Correct |
406 ms |
524 KB |
Output is correct |
11 |
Correct |
23 ms |
472 KB |
Output is correct |
12 |
Correct |
240 ms |
652 KB |
Output is correct |
13 |
Correct |
248 ms |
544 KB |
Output is correct |
14 |
Correct |
239 ms |
656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
368 ms |
712 KB |
Output is correct |
2 |
Correct |
428 ms |
488 KB |
Output is correct |
3 |
Correct |
411 ms |
484 KB |
Output is correct |
4 |
Correct |
384 ms |
552 KB |
Output is correct |
5 |
Correct |
206 ms |
588 KB |
Output is correct |
6 |
Correct |
371 ms |
568 KB |
Output is correct |
7 |
Correct |
201 ms |
484 KB |
Output is correct |
8 |
Correct |
285 ms |
532 KB |
Output is correct |
9 |
Correct |
386 ms |
588 KB |
Output is correct |
10 |
Correct |
406 ms |
524 KB |
Output is correct |
11 |
Correct |
23 ms |
472 KB |
Output is correct |
12 |
Correct |
240 ms |
652 KB |
Output is correct |
13 |
Correct |
248 ms |
544 KB |
Output is correct |
14 |
Correct |
239 ms |
656 KB |
Output is correct |
15 |
Correct |
389 ms |
472 KB |
Output is correct |
16 |
Correct |
370 ms |
680 KB |
Output is correct |
17 |
Correct |
384 ms |
568 KB |
Output is correct |
18 |
Correct |
410 ms |
672 KB |
Output is correct |
19 |
Correct |
416 ms |
660 KB |
Output is correct |
20 |
Correct |
423 ms |
668 KB |
Output is correct |
21 |
Correct |
422 ms |
552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
444 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
18 ms |
424 KB |
Output is correct |
14 |
Correct |
14 ms |
628 KB |
Output is correct |
15 |
Correct |
13 ms |
468 KB |
Output is correct |
16 |
Correct |
17 ms |
652 KB |
Output is correct |
17 |
Correct |
16 ms |
588 KB |
Output is correct |
18 |
Correct |
20 ms |
588 KB |
Output is correct |
19 |
Correct |
368 ms |
712 KB |
Output is correct |
20 |
Correct |
428 ms |
488 KB |
Output is correct |
21 |
Correct |
411 ms |
484 KB |
Output is correct |
22 |
Correct |
384 ms |
552 KB |
Output is correct |
23 |
Correct |
206 ms |
588 KB |
Output is correct |
24 |
Correct |
371 ms |
568 KB |
Output is correct |
25 |
Correct |
201 ms |
484 KB |
Output is correct |
26 |
Correct |
285 ms |
532 KB |
Output is correct |
27 |
Correct |
386 ms |
588 KB |
Output is correct |
28 |
Correct |
406 ms |
524 KB |
Output is correct |
29 |
Correct |
23 ms |
472 KB |
Output is correct |
30 |
Correct |
240 ms |
652 KB |
Output is correct |
31 |
Correct |
248 ms |
544 KB |
Output is correct |
32 |
Correct |
239 ms |
656 KB |
Output is correct |
33 |
Correct |
389 ms |
472 KB |
Output is correct |
34 |
Correct |
370 ms |
680 KB |
Output is correct |
35 |
Correct |
384 ms |
568 KB |
Output is correct |
36 |
Correct |
410 ms |
672 KB |
Output is correct |
37 |
Correct |
416 ms |
660 KB |
Output is correct |
38 |
Correct |
423 ms |
668 KB |
Output is correct |
39 |
Correct |
422 ms |
552 KB |
Output is correct |
40 |
Correct |
396 ms |
2124 KB |
Output is correct |
41 |
Correct |
40 ms |
616 KB |
Output is correct |
42 |
Correct |
402 ms |
2096 KB |
Output is correct |
43 |
Correct |
420 ms |
1696 KB |
Output is correct |
44 |
Correct |
407 ms |
1772 KB |
Output is correct |
45 |
Correct |
449 ms |
8208 KB |
Output is correct |
46 |
Correct |
50 ms |
1612 KB |
Output is correct |
47 |
Correct |
476 ms |
8304 KB |
Output is correct |
48 |
Correct |
443 ms |
6536 KB |
Output is correct |
49 |
Correct |
454 ms |
7160 KB |
Output is correct |