Submission #522302

# Submission time Handle Problem Language Result Execution time Memory
522302 2022-02-04T14:42:11 Z Lobo Lottery (CEOI18_lot) C++17
100 / 100
984 ms 8416 KB
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
// #define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 10100

int n, l, a[maxn], ans1[maxn], ans[maxn], ant[maxn], qr[110], qtd[maxn], ansq[110][maxn];

void solve() {
    cin >> n >> l;

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

    int q; cin >> q;

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

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

        qtd[ans1[i]]++;
    }

    for(int j = 1; j <= l; j++) {
        qtd[j]+= qtd[j-1];
    }

    for(int j = 1; j <= q; j++) {
        ansq[j][1] = qtd[qr[j]];
    }

    for(int i = 1; i <= n-l+1; i++) {
        ant[i] = ans1[i];
    }

    for(int i = 2; i <= n-l+1; i++) {
        ans[1] = ans1[i];

        for(int j = 0; j <= l; j++) {
            qtd[j] = 0;
        }

        qtd[ans[1]]++;
        for(int j = 2; j <= n-l+1; j++) {
            ans[j] = ant[j-1];
            if(a[j-1] == a[i-1]) ans[j]++;
            if(a[j+l-1] == a[i+l-1]) ans[j]--;

            qtd[ans[j]]++;
        }

        for(int j = 1; j <= l; j++) {
            qtd[j]+= qtd[j-1];
        }

        for(int j = 1; j <= q; j++) {
            ansq[j][i] = qtd[qr[j]];
        }

        for(int j = 1; j <= n-l+1; j++) {
            ant[j] = ans[j];
        }
    }

    for(int i = 1; i <= q; i++) {
        for(int j = 1; j <= n-l+1; j++) {
            cout << ansq[i][j]-1 << " ";
        }
        cout << endl;
    }

}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);
    
    int tt = 1;
    // cin >> tt;
    while(tt--) solve();

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 452 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 452 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 24 ms 428 KB Output is correct
14 Correct 13 ms 608 KB Output is correct
15 Correct 11 ms 480 KB Output is correct
16 Correct 16 ms 680 KB Output is correct
17 Correct 14 ms 608 KB Output is correct
18 Correct 16 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 679 ms 620 KB Output is correct
2 Correct 861 ms 716 KB Output is correct
3 Correct 484 ms 636 KB Output is correct
4 Correct 353 ms 592 KB Output is correct
5 Correct 185 ms 556 KB Output is correct
6 Correct 328 ms 592 KB Output is correct
7 Correct 178 ms 708 KB Output is correct
8 Correct 268 ms 816 KB Output is correct
9 Correct 348 ms 608 KB Output is correct
10 Correct 364 ms 836 KB Output is correct
11 Correct 25 ms 332 KB Output is correct
12 Correct 240 ms 480 KB Output is correct
13 Correct 219 ms 544 KB Output is correct
14 Correct 236 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 679 ms 620 KB Output is correct
2 Correct 861 ms 716 KB Output is correct
3 Correct 484 ms 636 KB Output is correct
4 Correct 353 ms 592 KB Output is correct
5 Correct 185 ms 556 KB Output is correct
6 Correct 328 ms 592 KB Output is correct
7 Correct 178 ms 708 KB Output is correct
8 Correct 268 ms 816 KB Output is correct
9 Correct 348 ms 608 KB Output is correct
10 Correct 364 ms 836 KB Output is correct
11 Correct 25 ms 332 KB Output is correct
12 Correct 240 ms 480 KB Output is correct
13 Correct 219 ms 544 KB Output is correct
14 Correct 236 ms 544 KB Output is correct
15 Correct 445 ms 492 KB Output is correct
16 Correct 321 ms 824 KB Output is correct
17 Correct 368 ms 596 KB Output is correct
18 Correct 355 ms 720 KB Output is correct
19 Correct 352 ms 572 KB Output is correct
20 Correct 352 ms 832 KB Output is correct
21 Correct 354 ms 732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 452 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 24 ms 428 KB Output is correct
14 Correct 13 ms 608 KB Output is correct
15 Correct 11 ms 480 KB Output is correct
16 Correct 16 ms 680 KB Output is correct
17 Correct 14 ms 608 KB Output is correct
18 Correct 16 ms 588 KB Output is correct
19 Correct 679 ms 620 KB Output is correct
20 Correct 861 ms 716 KB Output is correct
21 Correct 484 ms 636 KB Output is correct
22 Correct 353 ms 592 KB Output is correct
23 Correct 185 ms 556 KB Output is correct
24 Correct 328 ms 592 KB Output is correct
25 Correct 178 ms 708 KB Output is correct
26 Correct 268 ms 816 KB Output is correct
27 Correct 348 ms 608 KB Output is correct
28 Correct 364 ms 836 KB Output is correct
29 Correct 25 ms 332 KB Output is correct
30 Correct 240 ms 480 KB Output is correct
31 Correct 219 ms 544 KB Output is correct
32 Correct 236 ms 544 KB Output is correct
33 Correct 445 ms 492 KB Output is correct
34 Correct 321 ms 824 KB Output is correct
35 Correct 368 ms 596 KB Output is correct
36 Correct 355 ms 720 KB Output is correct
37 Correct 352 ms 572 KB Output is correct
38 Correct 352 ms 832 KB Output is correct
39 Correct 354 ms 732 KB Output is correct
40 Correct 920 ms 2024 KB Output is correct
41 Correct 34 ms 708 KB Output is correct
42 Correct 369 ms 2036 KB Output is correct
43 Correct 348 ms 1792 KB Output is correct
44 Correct 354 ms 1848 KB Output is correct
45 Correct 984 ms 8296 KB Output is correct
46 Correct 40 ms 1604 KB Output is correct
47 Correct 426 ms 8416 KB Output is correct
48 Correct 405 ms 6852 KB Output is correct
49 Correct 400 ms 7380 KB Output is correct