Submission #983525

# Submission time Handle Problem Language Result Execution time Memory
983525 2024-05-15T15:37:03 Z LOLOLO Lottery (CEOI18_lot) C++11
100 / 100
238 ms 12628 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
#define           f     first
#define           s     second
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (int)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 1e4 + 10;
int a[N], f[N], id[N], nxt[N];
int add[110][N];
vector <int> lst[110];

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

    mem(nxt, 0x3f);
    int n, l;
    cin >> n >> l;

    nxt[l + 1] = l + 1;
    vector <int> cnt(n - l + 1, 0);

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    vector <int> ask;

    int cc = 1;
    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        nxt[x] = x;
        if (id[x] == 0) {
            id[x] = cc;
            cc++;
        }

        ask.pb(x);
    }

    for (int i = l; i >= 0; i--)
        nxt[i] = min(nxt[i + 1], nxt[i]);

    for (int d = 1; d <= n; d++) {
        mem(f, 0);
        for (int i = n; i >= d + 1; i--) {
            f[i] = f[i + 1] + (a[i] != a[i - d]);
            if (i + l <= n + 1) {
                int cnt = id[nxt[f[i] - f[i + l]]];
                add[cnt][i - 1]++;
                add[cnt][i - d - 1]++;
            }
        }
    }

    for (int i = 0; i <= l; i++) {
        if (id[i]) {
            for (int j = 0; j < n - l + 1; j++) {
                cnt[j] += add[id[i]][j];
            }

            lst[id[i]] = cnt;  
        }
    }

    for (auto x : ask) {
        for (auto t : lst[id[x]])
            cout << t << " ";

        cout << '\n';
    }

    return 0;
}   
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 8 ms 2668 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 7 ms 660 KB Output is correct
16 Correct 9 ms 2896 KB Output is correct
17 Correct 9 ms 2648 KB Output is correct
18 Correct 9 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 708 KB Output is correct
2 Correct 145 ms 600 KB Output is correct
3 Correct 150 ms 704 KB Output is correct
4 Correct 158 ms 784 KB Output is correct
5 Correct 132 ms 720 KB Output is correct
6 Correct 154 ms 772 KB Output is correct
7 Correct 133 ms 712 KB Output is correct
8 Correct 137 ms 600 KB Output is correct
9 Correct 148 ms 784 KB Output is correct
10 Correct 152 ms 780 KB Output is correct
11 Correct 14 ms 604 KB Output is correct
12 Correct 117 ms 704 KB Output is correct
13 Correct 143 ms 716 KB Output is correct
14 Correct 137 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 708 KB Output is correct
2 Correct 145 ms 600 KB Output is correct
3 Correct 150 ms 704 KB Output is correct
4 Correct 158 ms 784 KB Output is correct
5 Correct 132 ms 720 KB Output is correct
6 Correct 154 ms 772 KB Output is correct
7 Correct 133 ms 712 KB Output is correct
8 Correct 137 ms 600 KB Output is correct
9 Correct 148 ms 784 KB Output is correct
10 Correct 152 ms 780 KB Output is correct
11 Correct 14 ms 604 KB Output is correct
12 Correct 117 ms 704 KB Output is correct
13 Correct 143 ms 716 KB Output is correct
14 Correct 137 ms 724 KB Output is correct
15 Correct 153 ms 604 KB Output is correct
16 Correct 145 ms 772 KB Output is correct
17 Correct 148 ms 780 KB Output is correct
18 Correct 175 ms 768 KB Output is correct
19 Correct 145 ms 788 KB Output is correct
20 Correct 148 ms 796 KB Output is correct
21 Correct 144 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 8 ms 2668 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 7 ms 660 KB Output is correct
16 Correct 9 ms 2896 KB Output is correct
17 Correct 9 ms 2648 KB Output is correct
18 Correct 9 ms 2652 KB Output is correct
19 Correct 146 ms 708 KB Output is correct
20 Correct 145 ms 600 KB Output is correct
21 Correct 150 ms 704 KB Output is correct
22 Correct 158 ms 784 KB Output is correct
23 Correct 132 ms 720 KB Output is correct
24 Correct 154 ms 772 KB Output is correct
25 Correct 133 ms 712 KB Output is correct
26 Correct 137 ms 600 KB Output is correct
27 Correct 148 ms 784 KB Output is correct
28 Correct 152 ms 780 KB Output is correct
29 Correct 14 ms 604 KB Output is correct
30 Correct 117 ms 704 KB Output is correct
31 Correct 143 ms 716 KB Output is correct
32 Correct 137 ms 724 KB Output is correct
33 Correct 153 ms 604 KB Output is correct
34 Correct 145 ms 772 KB Output is correct
35 Correct 148 ms 780 KB Output is correct
36 Correct 175 ms 768 KB Output is correct
37 Correct 145 ms 788 KB Output is correct
38 Correct 148 ms 796 KB Output is correct
39 Correct 144 ms 780 KB Output is correct
40 Correct 184 ms 4312 KB Output is correct
41 Correct 129 ms 2720 KB Output is correct
42 Correct 157 ms 4176 KB Output is correct
43 Correct 152 ms 3916 KB Output is correct
44 Correct 183 ms 3936 KB Output is correct
45 Correct 238 ms 12432 KB Output is correct
46 Correct 135 ms 3268 KB Output is correct
47 Correct 195 ms 12628 KB Output is correct
48 Correct 192 ms 10356 KB Output is correct
49 Correct 189 ms 10868 KB Output is correct