Submission #155651

# Submission time Handle Problem Language Result Execution time Memory
155651 2019-09-29T14:52:13 Z karma Lottery (CEOI18_lot) C++14
100 / 100
820 ms 8316 KB
#include<bits/stdc++.h>
#define Task     "test"
#define pb       emplace_back

using namespace std;

const int N = int(1e4) + 2;

int f[N][103], pre[N], a[N], pos[N];
int n, l, lim, q, k[105], cnt;
bool vis[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> l; lim = n - l + 1;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    cin >> q;
    for(int i = 1; i <= q; ++i) cin >> k[i], vis[k[i]] = 1;
    cnt = 1;
    for(int i = 0; i <= l; ++i) {
        pos[i] = cnt;
        if(vis[i]) ++cnt;
    }
    for(int j = 1; j <= lim; ++j) {
        for(int i = 1; i <= n; ++i) {
            if(i + j > n) break;
            if(a[i] != a[i + j]) pre[i] = pre[i - 1] + 1;
            else pre[i] = pre[i - 1];
        }
        for(int i = 0; i < lim; ++i) {
            if(i + j + l > n) break;
            ++f[i + 1][pos[pre[i + l] - pre[i]]];
            ++f[i + j + 1][pos[pre[i + l] - pre[i]]];
        }
    }
    for(int j = 1; j < cnt; ++j) {
        for(int i = 1; i <= lim; ++i) f[i][j] += f[i][j - 1];
    }
    for(int j = 1; j <= q; ++j) {
        for(int i = 1; i <= lim; ++i) cout << f[i][pos[k[j]]] << ' ';
        cout << '\n';
    }
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 23 ms 1236 KB Output is correct
14 Correct 16 ms 1016 KB Output is correct
15 Correct 15 ms 888 KB Output is correct
16 Correct 21 ms 1252 KB Output is correct
17 Correct 21 ms 1144 KB Output is correct
18 Correct 20 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 703 ms 4572 KB Output is correct
2 Correct 708 ms 4600 KB Output is correct
3 Correct 529 ms 4600 KB Output is correct
4 Correct 503 ms 4600 KB Output is correct
5 Correct 192 ms 2424 KB Output is correct
6 Correct 474 ms 4220 KB Output is correct
7 Correct 179 ms 2508 KB Output is correct
8 Correct 292 ms 3304 KB Output is correct
9 Correct 495 ms 4372 KB Output is correct
10 Correct 500 ms 4420 KB Output is correct
11 Correct 27 ms 1272 KB Output is correct
12 Correct 289 ms 3320 KB Output is correct
13 Correct 249 ms 2980 KB Output is correct
14 Correct 242 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 703 ms 4572 KB Output is correct
2 Correct 708 ms 4600 KB Output is correct
3 Correct 529 ms 4600 KB Output is correct
4 Correct 503 ms 4600 KB Output is correct
5 Correct 192 ms 2424 KB Output is correct
6 Correct 474 ms 4220 KB Output is correct
7 Correct 179 ms 2508 KB Output is correct
8 Correct 292 ms 3304 KB Output is correct
9 Correct 495 ms 4372 KB Output is correct
10 Correct 500 ms 4420 KB Output is correct
11 Correct 27 ms 1272 KB Output is correct
12 Correct 289 ms 3320 KB Output is correct
13 Correct 249 ms 2980 KB Output is correct
14 Correct 242 ms 2808 KB Output is correct
15 Correct 510 ms 4368 KB Output is correct
16 Correct 449 ms 4088 KB Output is correct
17 Correct 528 ms 4488 KB Output is correct
18 Correct 509 ms 4460 KB Output is correct
19 Correct 514 ms 4456 KB Output is correct
20 Correct 525 ms 4472 KB Output is correct
21 Correct 516 ms 4500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 23 ms 1236 KB Output is correct
14 Correct 16 ms 1016 KB Output is correct
15 Correct 15 ms 888 KB Output is correct
16 Correct 21 ms 1252 KB Output is correct
17 Correct 21 ms 1144 KB Output is correct
18 Correct 20 ms 1144 KB Output is correct
19 Correct 703 ms 4572 KB Output is correct
20 Correct 708 ms 4600 KB Output is correct
21 Correct 529 ms 4600 KB Output is correct
22 Correct 503 ms 4600 KB Output is correct
23 Correct 192 ms 2424 KB Output is correct
24 Correct 474 ms 4220 KB Output is correct
25 Correct 179 ms 2508 KB Output is correct
26 Correct 292 ms 3304 KB Output is correct
27 Correct 495 ms 4372 KB Output is correct
28 Correct 500 ms 4420 KB Output is correct
29 Correct 27 ms 1272 KB Output is correct
30 Correct 289 ms 3320 KB Output is correct
31 Correct 249 ms 2980 KB Output is correct
32 Correct 242 ms 2808 KB Output is correct
33 Correct 510 ms 4368 KB Output is correct
34 Correct 449 ms 4088 KB Output is correct
35 Correct 528 ms 4488 KB Output is correct
36 Correct 509 ms 4460 KB Output is correct
37 Correct 514 ms 4456 KB Output is correct
38 Correct 525 ms 4472 KB Output is correct
39 Correct 516 ms 4500 KB Output is correct
40 Correct 717 ms 5232 KB Output is correct
41 Correct 35 ms 888 KB Output is correct
42 Correct 525 ms 5240 KB Output is correct
43 Correct 499 ms 4728 KB Output is correct
44 Correct 501 ms 4876 KB Output is correct
45 Correct 820 ms 8312 KB Output is correct
46 Correct 42 ms 1144 KB Output is correct
47 Correct 611 ms 8316 KB Output is correct
48 Correct 577 ms 6520 KB Output is correct
49 Correct 592 ms 7160 KB Output is correct