Submission #155647

# Submission time Handle Problem Language Result Execution time Memory
155647 2019-09-29T14:34:40 Z karma Lottery (CEOI18_lot) C++14
45 / 100
1899 ms 41364 KB
#include<bits/stdc++.h>
#define Task     "test"
#define pb       emplace_back

using namespace std;

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

int f[N][N], pre[N], a[N];
int n, l, lim, q, k;

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];
    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][pre[i + l] - pre[i]];
            ++f[i + j + 1][pre[i + l] - pre[i]];
        }
    }
    for(int j = 0; j <= l; ++j) {
        for(int i = 1; i <= lim; ++i) {
            f[i][j] += f[i][j - 1];
            //cout << f[i][j] << ' ';
        }
        //cout << '\n';
    }
    cin >> q;
    while(q --) {
        cin >> k;
        for(int i = 1; i <= lim; ++i) cout << f[i][k] << ' ';
        cout << '\n';
    }
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:16: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:17: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 504 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 1016 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
11 Correct 4 ms 1528 KB Output is correct
12 Correct 4 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 1016 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
11 Correct 4 ms 1528 KB Output is correct
12 Correct 4 ms 1528 KB Output is correct
13 Correct 37 ms 8572 KB Output is correct
14 Correct 28 ms 9380 KB Output is correct
15 Correct 25 ms 9336 KB Output is correct
16 Correct 36 ms 9336 KB Output is correct
17 Correct 33 ms 9336 KB Output is correct
18 Correct 31 ms 9464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1899 ms 41364 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1899 ms 41364 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 1016 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
11 Correct 4 ms 1528 KB Output is correct
12 Correct 4 ms 1528 KB Output is correct
13 Correct 37 ms 8572 KB Output is correct
14 Correct 28 ms 9380 KB Output is correct
15 Correct 25 ms 9336 KB Output is correct
16 Correct 36 ms 9336 KB Output is correct
17 Correct 33 ms 9336 KB Output is correct
18 Correct 31 ms 9464 KB Output is correct
19 Runtime error 1899 ms 41364 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
20 Halted 0 ms 0 KB -