Submission #217879

# Submission time Handle Problem Language Result Execution time Memory
217879 2020-03-31T07:18:15 Z PeppaPig Lottery (CEOI18_lot) C++14
100 / 100
1488 ms 8468 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e4+5;

int n, l, q;
int A[N], Q[N], cnt[N][105];
vector<int> coord;

int get(int x) { return lower_bound(coord.begin(), coord.end(), x) - coord.begin() + 1; }

int main() {
    scanf("%d %d", &n, &l);
    for(int i = 1; i <= n; i++) scanf("%d", A + i);
    scanf("%d", &q);
    for(int i = 1; i <= q; i++) {
        scanf("%d", Q + i);
        coord.emplace_back(Q[i]);
    }
    sort(coord.begin(), coord.end());
    coord.resize(unique(coord.begin(), coord.end()) - coord.begin());

    for(int dif = 1; dif <= n - l; dif++) {
        int match = 0;
        for(int i = 1; i <= l; i++) match += (A[i] == A[i + dif]);
        ++cnt[1][get(l - match)], ++cnt[dif + 1][get(l - match)];
        for(int i = l + 1, j = i + dif; j <= n; i++, j++) {
            if(A[i - l] == A[j - l]) --match;
            if(A[i] == A[j]) ++match;
            int idx = get(l - match);
            ++cnt[i - l + 1][idx], ++cnt[j - l + 1][idx];
        }
    }
    for(int i = 1; i <= n - l + 1; i++) for(int j = 1; j <= coord.size(); j++)
        cnt[i][j] += cnt[i][j - 1];
    for(int i = 1; i <= q; i++) {
        int idx = get(Q[i]);
        for(int j = 1; j <= n - l + 1; j++) printf("%d ", cnt[j][idx]);
        printf("\n");
    }

    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:35:58: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i <= n - l + 1; i++) for(int j = 1; j <= coord.size(); j++)
                                                        ~~^~~~~~~~~~~~~~~
lot.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &l);
     ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:15:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%d", A + i);
                                 ~~~~~^~~~~~~~~~~~~
lot.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
lot.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", Q + i);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 512 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 512 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 7 ms 512 KB Output is correct
13 Correct 30 ms 1152 KB Output is correct
14 Correct 18 ms 1024 KB Output is correct
15 Correct 18 ms 1024 KB Output is correct
16 Correct 28 ms 1152 KB Output is correct
17 Correct 26 ms 1152 KB Output is correct
18 Correct 26 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 747 ms 4600 KB Output is correct
2 Correct 957 ms 4600 KB Output is correct
3 Correct 505 ms 4600 KB Output is correct
4 Correct 424 ms 4480 KB Output is correct
5 Correct 135 ms 2560 KB Output is correct
6 Correct 396 ms 4348 KB Output is correct
7 Correct 113 ms 2560 KB Output is correct
8 Correct 200 ms 3328 KB Output is correct
9 Correct 407 ms 4472 KB Output is correct
10 Correct 449 ms 4600 KB Output is correct
11 Correct 29 ms 1152 KB Output is correct
12 Correct 269 ms 3328 KB Output is correct
13 Correct 179 ms 2944 KB Output is correct
14 Correct 191 ms 3072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 747 ms 4600 KB Output is correct
2 Correct 957 ms 4600 KB Output is correct
3 Correct 505 ms 4600 KB Output is correct
4 Correct 424 ms 4480 KB Output is correct
5 Correct 135 ms 2560 KB Output is correct
6 Correct 396 ms 4348 KB Output is correct
7 Correct 113 ms 2560 KB Output is correct
8 Correct 200 ms 3328 KB Output is correct
9 Correct 407 ms 4472 KB Output is correct
10 Correct 449 ms 4600 KB Output is correct
11 Correct 29 ms 1152 KB Output is correct
12 Correct 269 ms 3328 KB Output is correct
13 Correct 179 ms 2944 KB Output is correct
14 Correct 191 ms 3072 KB Output is correct
15 Correct 487 ms 4352 KB Output is correct
16 Correct 370 ms 4216 KB Output is correct
17 Correct 457 ms 4608 KB Output is correct
18 Correct 435 ms 4600 KB Output is correct
19 Correct 428 ms 4600 KB Output is correct
20 Correct 431 ms 4728 KB Output is correct
21 Correct 441 ms 4600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 512 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 7 ms 512 KB Output is correct
13 Correct 30 ms 1152 KB Output is correct
14 Correct 18 ms 1024 KB Output is correct
15 Correct 18 ms 1024 KB Output is correct
16 Correct 28 ms 1152 KB Output is correct
17 Correct 26 ms 1152 KB Output is correct
18 Correct 26 ms 1144 KB Output is correct
19 Correct 747 ms 4600 KB Output is correct
20 Correct 957 ms 4600 KB Output is correct
21 Correct 505 ms 4600 KB Output is correct
22 Correct 424 ms 4480 KB Output is correct
23 Correct 135 ms 2560 KB Output is correct
24 Correct 396 ms 4348 KB Output is correct
25 Correct 113 ms 2560 KB Output is correct
26 Correct 200 ms 3328 KB Output is correct
27 Correct 407 ms 4472 KB Output is correct
28 Correct 449 ms 4600 KB Output is correct
29 Correct 29 ms 1152 KB Output is correct
30 Correct 269 ms 3328 KB Output is correct
31 Correct 179 ms 2944 KB Output is correct
32 Correct 191 ms 3072 KB Output is correct
33 Correct 487 ms 4352 KB Output is correct
34 Correct 370 ms 4216 KB Output is correct
35 Correct 457 ms 4608 KB Output is correct
36 Correct 435 ms 4600 KB Output is correct
37 Correct 428 ms 4600 KB Output is correct
38 Correct 431 ms 4728 KB Output is correct
39 Correct 441 ms 4600 KB Output is correct
40 Correct 1173 ms 5264 KB Output is correct
41 Correct 22 ms 896 KB Output is correct
42 Correct 649 ms 5368 KB Output is correct
43 Correct 591 ms 4812 KB Output is correct
44 Correct 598 ms 4984 KB Output is correct
45 Correct 1488 ms 8312 KB Output is correct
46 Correct 31 ms 1144 KB Output is correct
47 Correct 876 ms 8468 KB Output is correct
48 Correct 808 ms 6520 KB Output is correct
49 Correct 802 ms 7160 KB Output is correct