답안 #320767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320767 2020-11-09T19:28:16 Z dolphingarlic Lottery (CEOI18_lot) C++14
100 / 100
587 ms 12388 KB
#include <bits/stdc++.h>
using namespace std;

int a[10000], lb[10001], pref[101][10000], ans[100][10000];
pair<int, int> k[100];

int main() {
    int n, l, q;
    scanf("%d %d", &n, &l);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &k[i].first);
        k[i].second = i;
    }
    sort(k, k + q);
    fill(lb, lb + l + 1, q);
    for (int t = q - 1; ~t; t--) {
        for (int i = 0; i <= l; i++) if (i <= k[t].first) lb[i] = t;
    }

    for (int dx = 1; dx <= n - l; dx++) {
        int diff = 0;
        for (int p = 0; p < l; p++) diff += (a[p] != a[dx + p]);
        pref[lb[diff]][0]++, pref[lb[diff]][dx]++;
        for (int i = 1; i <= n - l - dx; i++) {
            diff += (a[i + l - 1] != a[i + dx + l - 1]) - (a[i - 1] != a[i + dx - 1]);
            pref[lb[diff]][i]++, pref[lb[diff]][i + dx]++;
        }
    }
    for (int t = 0; t < q; t++) for (int i = 0; i <= n - l; i++) {
        if (t) pref[t][i] += pref[t - 1][i];
        ans[k[t].second][i] = pref[t][i];
    }
    for (int t = 0; t < q; t++) {
        for (int i = 0; i <= n - l; i++) printf("%d ", ans[t][i]);
        printf("\n");
    }
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d %d", &n, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:10:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     for (int i = 0; i < n; i++) scanf("%d", a + i);
      |                                 ~~~~~^~~~~~~~~~~~~
lot.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
lot.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         scanf("%d", &k[i].first);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 22 ms 492 KB Output is correct
14 Correct 14 ms 748 KB Output is correct
15 Correct 12 ms 620 KB Output is correct
16 Correct 20 ms 876 KB Output is correct
17 Correct 19 ms 876 KB Output is correct
18 Correct 18 ms 868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 612 KB Output is correct
2 Correct 470 ms 492 KB Output is correct
3 Correct 470 ms 612 KB Output is correct
4 Correct 453 ms 612 KB Output is correct
5 Correct 139 ms 612 KB Output is correct
6 Correct 415 ms 612 KB Output is correct
7 Correct 139 ms 612 KB Output is correct
8 Correct 248 ms 564 KB Output is correct
9 Correct 445 ms 600 KB Output is correct
10 Correct 453 ms 596 KB Output is correct
11 Correct 21 ms 364 KB Output is correct
12 Correct 240 ms 612 KB Output is correct
13 Correct 183 ms 564 KB Output is correct
14 Correct 184 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 612 KB Output is correct
2 Correct 470 ms 492 KB Output is correct
3 Correct 470 ms 612 KB Output is correct
4 Correct 453 ms 612 KB Output is correct
5 Correct 139 ms 612 KB Output is correct
6 Correct 415 ms 612 KB Output is correct
7 Correct 139 ms 612 KB Output is correct
8 Correct 248 ms 564 KB Output is correct
9 Correct 445 ms 600 KB Output is correct
10 Correct 453 ms 596 KB Output is correct
11 Correct 21 ms 364 KB Output is correct
12 Correct 240 ms 612 KB Output is correct
13 Correct 183 ms 564 KB Output is correct
14 Correct 184 ms 612 KB Output is correct
15 Correct 445 ms 612 KB Output is correct
16 Correct 399 ms 612 KB Output is correct
17 Correct 477 ms 612 KB Output is correct
18 Correct 462 ms 740 KB Output is correct
19 Correct 470 ms 608 KB Output is correct
20 Correct 459 ms 600 KB Output is correct
21 Correct 460 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 22 ms 492 KB Output is correct
14 Correct 14 ms 748 KB Output is correct
15 Correct 12 ms 620 KB Output is correct
16 Correct 20 ms 876 KB Output is correct
17 Correct 19 ms 876 KB Output is correct
18 Correct 18 ms 868 KB Output is correct
19 Correct 473 ms 612 KB Output is correct
20 Correct 470 ms 492 KB Output is correct
21 Correct 470 ms 612 KB Output is correct
22 Correct 453 ms 612 KB Output is correct
23 Correct 139 ms 612 KB Output is correct
24 Correct 415 ms 612 KB Output is correct
25 Correct 139 ms 612 KB Output is correct
26 Correct 248 ms 564 KB Output is correct
27 Correct 445 ms 600 KB Output is correct
28 Correct 453 ms 596 KB Output is correct
29 Correct 21 ms 364 KB Output is correct
30 Correct 240 ms 612 KB Output is correct
31 Correct 183 ms 564 KB Output is correct
32 Correct 184 ms 612 KB Output is correct
33 Correct 445 ms 612 KB Output is correct
34 Correct 399 ms 612 KB Output is correct
35 Correct 477 ms 612 KB Output is correct
36 Correct 462 ms 740 KB Output is correct
37 Correct 470 ms 608 KB Output is correct
38 Correct 459 ms 600 KB Output is correct
39 Correct 460 ms 612 KB Output is correct
40 Correct 502 ms 2716 KB Output is correct
41 Correct 16 ms 876 KB Output is correct
42 Correct 488 ms 2936 KB Output is correct
43 Correct 455 ms 2616 KB Output is correct
44 Correct 467 ms 2656 KB Output is correct
45 Correct 587 ms 12132 KB Output is correct
46 Correct 26 ms 2412 KB Output is correct
47 Correct 569 ms 12388 KB Output is correct
48 Correct 536 ms 10468 KB Output is correct
49 Correct 540 ms 11120 KB Output is correct