답안 #217522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217522 2020-03-30T06:10:27 Z DystoriaX Lottery (CEOI18_lot) C++14
100 / 100
816 ms 8464 KB
#include <bits/stdc++.h>

using namespace std;

int n, l;
int a[10010], b[10010];
int cnt[110][10010];
int q, qr[110];
int nxt[10010];
vector<int> cmp;

int main(){
    scanf("%d%d", &n, &l);

    for(int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];

    scanf("%d", &q);

    for(int i = 1; i <= q; i++){
        scanf("%d", &qr[i]);

        cmp.emplace_back(qr[i]);
    }

    sort(cmp.begin(), cmp.end());

    int idx = 0;
    for(int i = 0; i <= n; i++){
        while(idx < q && cmp[idx] < i) idx++;

        nxt[i] = idx;
    }

    for(int d = 1; d < n - l + 1; d++){
        int diff = 0;

        for(int j = 1; j <= l; j++){
            if(a[j] != a[j + d]) diff++;
        }

        cnt[nxt[diff]][1]++;
        cnt[nxt[diff]][d + 1]++;

        for(int i = 2; i + l + d - 1 <= n; i++){
            if(a[i - 1] != a[i + d - 1]) diff--;
            if(a[i + l - 1] != a[i + l - 1 + d]) diff++;

            // cout << "Comparing " << i + l - 1 << " with " << i + l + d - 

            cnt[nxt[diff]][i]++;
            cnt[nxt[diff]][i + d]++;
        }
    }

    for(int i = 1; i <= n; i++){
        for(int k = 1; k <= q; k++)
            cnt[k][i] += cnt[k - 1][i];
    }

    for(int i = 1; i <= q; i++){
        for(int j = 1; j <= n - l + 1; j++){
            printf("%d ", cnt[nxt[qr[i]]][j]);
        }
        printf("\n");
    }
    
    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:13: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:51: 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]), b[i] = a[i];
                                 ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
lot.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
lot.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &qr[i]);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 4 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 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 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 4 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 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 18 ms 384 KB Output is correct
14 Correct 13 ms 640 KB Output is correct
15 Correct 12 ms 512 KB Output is correct
16 Correct 18 ms 640 KB Output is correct
17 Correct 15 ms 640 KB Output is correct
18 Correct 16 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 518 ms 632 KB Output is correct
2 Correct 609 ms 564 KB Output is correct
3 Correct 328 ms 636 KB Output is correct
4 Correct 266 ms 512 KB Output is correct
5 Correct 92 ms 512 KB Output is correct
6 Correct 247 ms 512 KB Output is correct
7 Correct 97 ms 512 KB Output is correct
8 Correct 166 ms 512 KB Output is correct
9 Correct 264 ms 632 KB Output is correct
10 Correct 259 ms 632 KB Output is correct
11 Correct 22 ms 384 KB Output is correct
12 Correct 156 ms 512 KB Output is correct
13 Correct 122 ms 632 KB Output is correct
14 Correct 131 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 518 ms 632 KB Output is correct
2 Correct 609 ms 564 KB Output is correct
3 Correct 328 ms 636 KB Output is correct
4 Correct 266 ms 512 KB Output is correct
5 Correct 92 ms 512 KB Output is correct
6 Correct 247 ms 512 KB Output is correct
7 Correct 97 ms 512 KB Output is correct
8 Correct 166 ms 512 KB Output is correct
9 Correct 264 ms 632 KB Output is correct
10 Correct 259 ms 632 KB Output is correct
11 Correct 22 ms 384 KB Output is correct
12 Correct 156 ms 512 KB Output is correct
13 Correct 122 ms 632 KB Output is correct
14 Correct 131 ms 512 KB Output is correct
15 Correct 341 ms 512 KB Output is correct
16 Correct 235 ms 560 KB Output is correct
17 Correct 292 ms 632 KB Output is correct
18 Correct 272 ms 512 KB Output is correct
19 Correct 270 ms 512 KB Output is correct
20 Correct 274 ms 512 KB Output is correct
21 Correct 273 ms 636 KB Output is correct
# 결과 실행 시간 메모리 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 4 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 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 18 ms 384 KB Output is correct
14 Correct 13 ms 640 KB Output is correct
15 Correct 12 ms 512 KB Output is correct
16 Correct 18 ms 640 KB Output is correct
17 Correct 15 ms 640 KB Output is correct
18 Correct 16 ms 640 KB Output is correct
19 Correct 518 ms 632 KB Output is correct
20 Correct 609 ms 564 KB Output is correct
21 Correct 328 ms 636 KB Output is correct
22 Correct 266 ms 512 KB Output is correct
23 Correct 92 ms 512 KB Output is correct
24 Correct 247 ms 512 KB Output is correct
25 Correct 97 ms 512 KB Output is correct
26 Correct 166 ms 512 KB Output is correct
27 Correct 264 ms 632 KB Output is correct
28 Correct 259 ms 632 KB Output is correct
29 Correct 22 ms 384 KB Output is correct
30 Correct 156 ms 512 KB Output is correct
31 Correct 122 ms 632 KB Output is correct
32 Correct 131 ms 512 KB Output is correct
33 Correct 341 ms 512 KB Output is correct
34 Correct 235 ms 560 KB Output is correct
35 Correct 292 ms 632 KB Output is correct
36 Correct 272 ms 512 KB Output is correct
37 Correct 270 ms 512 KB Output is correct
38 Correct 274 ms 512 KB Output is correct
39 Correct 273 ms 636 KB Output is correct
40 Correct 754 ms 2040 KB Output is correct
41 Correct 17 ms 1280 KB Output is correct
42 Correct 331 ms 2016 KB Output is correct
43 Correct 269 ms 1784 KB Output is correct
44 Correct 293 ms 1784 KB Output is correct
45 Correct 816 ms 8312 KB Output is correct
46 Correct 26 ms 4608 KB Output is correct
47 Correct 371 ms 8464 KB Output is correct
48 Correct 341 ms 6520 KB Output is correct
49 Correct 344 ms 7160 KB Output is correct