답안 #760928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760928 2023-06-18T23:04:11 Z MilosMilutinovic Lottery (CEOI18_lot) C++14
100 / 100
354 ms 8608 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
const int Q = 1e2 + 10;
int n, d, q, a[N], k[N], f[N][Q], nxt[N], id[N];
int main() {
    scanf("%d%d", &n, &d);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i <= n; i++)
        nxt[i] = -1;
    for (int i = 1; i <= q; i++)
        scanf("%d", &k[i]), nxt[k[i]] = k[i];
    for (int i = n - 1; i >= 0; i--)
        if (nxt[i] == -1)
            nxt[i] = nxt[i + 1];
    int pos = 0;
    for (int i = 0; i <= n; i++)
        if (nxt[i] == i)
            id[i] = ++pos;
    for (int l = 1; l + d - 1 <= n; l++) {
        int cnt = 0;
        for (int i = 1; i <= d; i++)
            cnt += (a[i] != a[l + i - 1]);
        for (int r = 1; l + (d - 1) + (r - 1) <= n; r++) {
            if (l + r - 1 != r && nxt[cnt] != -1) {
                f[r][id[nxt[cnt]]] += 1;
                f[l + r - 1][id[nxt[cnt]]] += 1;
            }
            cnt -= (a[l + r - 1] != a[r]);
            cnt += (a[l + r + d - 1] != a[r + d]);
        }
    }
    for (int i = 1; i <= q; i++) {
        for (int j = 1; j + d - 1 <= n; j++) {
            int cnt = 0;
            for (int x = 1; x <= id[k[i]]; x++)
                cnt += f[j][x];
            printf("%d ", cnt);
        }
        printf("\n");
    }
    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d", &n, &d);
      |     ~~~~~^~~~~~~~~~~~~~~~
lot.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         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:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d", &k[i]), nxt[k[i]] = k[i];
      |         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 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 0 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 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 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 0 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 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 9 ms 1236 KB Output is correct
14 Correct 6 ms 980 KB Output is correct
15 Correct 4 ms 852 KB Output is correct
16 Correct 9 ms 1096 KB Output is correct
17 Correct 6 ms 1108 KB Output is correct
18 Correct 5 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 4672 KB Output is correct
2 Correct 88 ms 4704 KB Output is correct
3 Correct 77 ms 4692 KB Output is correct
4 Correct 77 ms 3816 KB Output is correct
5 Correct 36 ms 520 KB Output is correct
6 Correct 70 ms 1336 KB Output is correct
7 Correct 64 ms 2636 KB Output is correct
8 Correct 120 ms 3492 KB Output is correct
9 Correct 79 ms 4360 KB Output is correct
10 Correct 79 ms 4444 KB Output is correct
11 Correct 5 ms 724 KB Output is correct
12 Correct 47 ms 1344 KB Output is correct
13 Correct 43 ms 468 KB Output is correct
14 Correct 43 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 4672 KB Output is correct
2 Correct 88 ms 4704 KB Output is correct
3 Correct 77 ms 4692 KB Output is correct
4 Correct 77 ms 3816 KB Output is correct
5 Correct 36 ms 520 KB Output is correct
6 Correct 70 ms 1336 KB Output is correct
7 Correct 64 ms 2636 KB Output is correct
8 Correct 120 ms 3492 KB Output is correct
9 Correct 79 ms 4360 KB Output is correct
10 Correct 79 ms 4444 KB Output is correct
11 Correct 5 ms 724 KB Output is correct
12 Correct 47 ms 1344 KB Output is correct
13 Correct 43 ms 468 KB Output is correct
14 Correct 43 ms 484 KB Output is correct
15 Correct 156 ms 4568 KB Output is correct
16 Correct 66 ms 2236 KB Output is correct
17 Correct 84 ms 4308 KB Output is correct
18 Correct 75 ms 2364 KB Output is correct
19 Correct 74 ms 2548 KB Output is correct
20 Correct 75 ms 4732 KB Output is correct
21 Correct 77 ms 4556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 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 0 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 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 9 ms 1236 KB Output is correct
14 Correct 6 ms 980 KB Output is correct
15 Correct 4 ms 852 KB Output is correct
16 Correct 9 ms 1096 KB Output is correct
17 Correct 6 ms 1108 KB Output is correct
18 Correct 5 ms 1116 KB Output is correct
19 Correct 161 ms 4672 KB Output is correct
20 Correct 88 ms 4704 KB Output is correct
21 Correct 77 ms 4692 KB Output is correct
22 Correct 77 ms 3816 KB Output is correct
23 Correct 36 ms 520 KB Output is correct
24 Correct 70 ms 1336 KB Output is correct
25 Correct 64 ms 2636 KB Output is correct
26 Correct 120 ms 3492 KB Output is correct
27 Correct 79 ms 4360 KB Output is correct
28 Correct 79 ms 4444 KB Output is correct
29 Correct 5 ms 724 KB Output is correct
30 Correct 47 ms 1344 KB Output is correct
31 Correct 43 ms 468 KB Output is correct
32 Correct 43 ms 484 KB Output is correct
33 Correct 156 ms 4568 KB Output is correct
34 Correct 66 ms 2236 KB Output is correct
35 Correct 84 ms 4308 KB Output is correct
36 Correct 75 ms 2364 KB Output is correct
37 Correct 74 ms 2548 KB Output is correct
38 Correct 75 ms 4732 KB Output is correct
39 Correct 77 ms 4556 KB Output is correct
40 Correct 233 ms 5432 KB Output is correct
41 Correct 10 ms 980 KB Output is correct
42 Correct 105 ms 5440 KB Output is correct
43 Correct 86 ms 4940 KB Output is correct
44 Correct 93 ms 5196 KB Output is correct
45 Correct 354 ms 8376 KB Output is correct
46 Correct 17 ms 1236 KB Output is correct
47 Correct 304 ms 8608 KB Output is correct
48 Correct 149 ms 6636 KB Output is correct
49 Correct 149 ms 7404 KB Output is correct