Submission #920167

# Submission time Handle Problem Language Result Execution time Memory
920167 2024-02-02T07:15:55 Z Ghulam_Junaid Lottery (CEOI18_lot) C++17
65 / 100
415 ms 16212 KB
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;
const int base = 727;

int score[2005][2005];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, l;
    cin >> n >> l;

    int a[n];
    for (int i = 0; i < n; i ++)
        cin >> a[i];

    if (n <= 2000){
        memset(score, 0, sizeof score);
        for (int i = 0; i + l <= n; i ++){
            for (int j = i + 1; j + l <= n; j ++)
                for (int k = 0; k < l; k ++)
                    score[i][j] += (a[i + k] != a[j + k]);
            for (int j = i + 1; j + l <= n; j ++)
                score[j][i] = score[i][j];
        }

        for (int i = 0; i + l <= n; i ++)
            sort(score[i], score[i] + n - l + 1);

        int q;
        cin >> q;
        while (q--){
            int k;
            cin >> k;

            for (int i = 0; i + l <= n; i ++){
                int ub = upper_bound(score[i], score[i] + n - l + 1, k) - score[i];
                cout << ub - 1 << " ";
            }
            cout << '\n';
        }

        return 0;
    }

    int Hash[n - l + 1];
    for (int i=0; i+l<=n; i++){
        int hsh = 0;
        for (int j=0; j<l; j++)
            hsh = ((1ll * hsh * base) + a[i + j]) % mod;
        Hash[i] = hsh;
    }

    int q;
    cin >> q;

    while (q--){
        int k;
        cin >> k;

        for (int i = 0; i + l <= n; i ++){
            int ans = -1;
            for (int j = 0; j + l <= n; j ++)
                ans += (Hash[i] == Hash[j]);
            cout << ans << " ";
        }
        cout << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 3 ms 15960 KB Output is correct
4 Correct 3 ms 15960 KB Output is correct
5 Correct 3 ms 15960 KB Output is correct
6 Correct 4 ms 15960 KB Output is correct
7 Correct 3 ms 15964 KB Output is correct
8 Correct 5 ms 15960 KB Output is correct
9 Correct 5 ms 15960 KB Output is correct
10 Correct 5 ms 15960 KB Output is correct
11 Correct 5 ms 15964 KB Output is correct
12 Correct 5 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 3 ms 15960 KB Output is correct
4 Correct 3 ms 15960 KB Output is correct
5 Correct 3 ms 15960 KB Output is correct
6 Correct 4 ms 15960 KB Output is correct
7 Correct 3 ms 15964 KB Output is correct
8 Correct 5 ms 15960 KB Output is correct
9 Correct 5 ms 15960 KB Output is correct
10 Correct 5 ms 15960 KB Output is correct
11 Correct 5 ms 15964 KB Output is correct
12 Correct 5 ms 15964 KB Output is correct
13 Correct 57 ms 16168 KB Output is correct
14 Correct 405 ms 16172 KB Output is correct
15 Correct 415 ms 16172 KB Output is correct
16 Correct 273 ms 16172 KB Output is correct
17 Correct 333 ms 16212 KB Output is correct
18 Correct 338 ms 16168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 344 KB Output is correct
2 Correct 62 ms 596 KB Output is correct
3 Correct 62 ms 344 KB Output is correct
4 Correct 69 ms 344 KB Output is correct
5 Correct 140 ms 496 KB Output is correct
6 Correct 86 ms 344 KB Output is correct
7 Correct 138 ms 344 KB Output is correct
8 Correct 134 ms 504 KB Output is correct
9 Correct 73 ms 348 KB Output is correct
10 Correct 69 ms 344 KB Output is correct
11 Correct 14 ms 604 KB Output is correct
12 Correct 100 ms 500 KB Output is correct
13 Correct 141 ms 496 KB Output is correct
14 Correct 142 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 344 KB Output is correct
2 Correct 62 ms 596 KB Output is correct
3 Correct 62 ms 344 KB Output is correct
4 Correct 69 ms 344 KB Output is correct
5 Correct 140 ms 496 KB Output is correct
6 Correct 86 ms 344 KB Output is correct
7 Correct 138 ms 344 KB Output is correct
8 Correct 134 ms 504 KB Output is correct
9 Correct 73 ms 348 KB Output is correct
10 Correct 69 ms 344 KB Output is correct
11 Correct 14 ms 604 KB Output is correct
12 Correct 100 ms 500 KB Output is correct
13 Correct 141 ms 496 KB Output is correct
14 Correct 142 ms 592 KB Output is correct
15 Incorrect 73 ms 532 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 3 ms 15960 KB Output is correct
4 Correct 3 ms 15960 KB Output is correct
5 Correct 3 ms 15960 KB Output is correct
6 Correct 4 ms 15960 KB Output is correct
7 Correct 3 ms 15964 KB Output is correct
8 Correct 5 ms 15960 KB Output is correct
9 Correct 5 ms 15960 KB Output is correct
10 Correct 5 ms 15960 KB Output is correct
11 Correct 5 ms 15964 KB Output is correct
12 Correct 5 ms 15964 KB Output is correct
13 Correct 57 ms 16168 KB Output is correct
14 Correct 405 ms 16172 KB Output is correct
15 Correct 415 ms 16172 KB Output is correct
16 Correct 273 ms 16172 KB Output is correct
17 Correct 333 ms 16212 KB Output is correct
18 Correct 338 ms 16168 KB Output is correct
19 Correct 62 ms 344 KB Output is correct
20 Correct 62 ms 596 KB Output is correct
21 Correct 62 ms 344 KB Output is correct
22 Correct 69 ms 344 KB Output is correct
23 Correct 140 ms 496 KB Output is correct
24 Correct 86 ms 344 KB Output is correct
25 Correct 138 ms 344 KB Output is correct
26 Correct 134 ms 504 KB Output is correct
27 Correct 73 ms 348 KB Output is correct
28 Correct 69 ms 344 KB Output is correct
29 Correct 14 ms 604 KB Output is correct
30 Correct 100 ms 500 KB Output is correct
31 Correct 141 ms 496 KB Output is correct
32 Correct 142 ms 592 KB Output is correct
33 Incorrect 73 ms 532 KB Output isn't correct
34 Halted 0 ms 0 KB -