Submission #807484

# Submission time Handle Problem Language Result Execution time Memory
807484 2023-08-04T18:02:22 Z Valaki2 Lottery (CEOI18_lot) C++14
80 / 100
383 ms 5128 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

const int maxn = 10000; //!!!!!
const int maxq = 100;

int n, l, q;
int v[1 + maxn];
int conv[1 + maxn];
int dp[1 + maxn];
int ans[1 + maxn][1 + maxq];
int qry[1 + maxq];

void solve() {
    cin >> n >> l;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    cin >> q;
    for(int i = n; i >= 0; i--) {
        conv[i] = n + 1;
    }
    for(int i = 1; i <= q; i++) {
        cin >> qry[i];
        conv[qry[i]] = i;
    }
    vector<pii> sorted;
    for(int i = n; i >= 0; i--) {
        if(conv[i] != n + 1) {
            sorted.pb(mp(i, conv[i]));
        }
    }
    sort(sorted.begin(), sorted.end());
    for(int i = n - 1; i >= 0; i--) {
        if(conv[i] == n + 1) {
            conv[i] = conv[i + 1];
        }
    }
    for(int offset = 1; offset <= n - l; offset++) {
        for(int i = 1; i <= offset; i++) {
            dp[i] = 0;
        }
        for(int i = 1 + offset; i <= n; i++) {
            dp[i] = dp[i - 1];
            if(v[i] != v[i - offset]) {
                dp[i]++;
            }
            if(i - l + 1 - offset >= 1) {
                #define a (i - l + 1)
                #define b (i - l + 1 - offset)
                #define dist (dp[i] - dp[i - l])
                ans[a][conv[dist]]++;
                ans[b][conv[dist]]++;
            }
        }
    }
    for(int i = 1; i <= n - l + 1; i++) {
        for(int j = 1; j < q; j++) {
            if(sorted[j].fi != sorted[j - 1].fi) {
                ans[i][sorted[j].se] += ans[i][sorted[j - 1].se];
            }
        }
    }
    for(int i = 1; i <= q; i++) {
        for(int j = 1; j <= n - l + 1; j++) {
            cout << ans[j][conv[qry[i]]] << " ";
        }
        cout << "\n";
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 10 ms 1108 KB Output is correct
14 Correct 10 ms 980 KB Output is correct
15 Correct 7 ms 868 KB Output is correct
16 Correct 12 ms 1108 KB Output is correct
17 Correct 10 ms 1044 KB Output is correct
18 Correct 10 ms 1084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 341 ms 4392 KB Output is correct
2 Correct 341 ms 4392 KB Output is correct
3 Correct 246 ms 4396 KB Output is correct
4 Correct 210 ms 4436 KB Output is correct
5 Correct 116 ms 2516 KB Output is correct
6 Correct 208 ms 4208 KB Output is correct
7 Correct 109 ms 2516 KB Output is correct
8 Correct 142 ms 3292 KB Output is correct
9 Correct 224 ms 4380 KB Output is correct
10 Correct 220 ms 4420 KB Output is correct
11 Correct 13 ms 1176 KB Output is correct
12 Correct 137 ms 3284 KB Output is correct
13 Correct 143 ms 2868 KB Output is correct
14 Correct 145 ms 2872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 341 ms 4392 KB Output is correct
2 Correct 341 ms 4392 KB Output is correct
3 Correct 246 ms 4396 KB Output is correct
4 Correct 210 ms 4436 KB Output is correct
5 Correct 116 ms 2516 KB Output is correct
6 Correct 208 ms 4208 KB Output is correct
7 Correct 109 ms 2516 KB Output is correct
8 Correct 142 ms 3292 KB Output is correct
9 Correct 224 ms 4380 KB Output is correct
10 Correct 220 ms 4420 KB Output is correct
11 Correct 13 ms 1176 KB Output is correct
12 Correct 137 ms 3284 KB Output is correct
13 Correct 143 ms 2868 KB Output is correct
14 Correct 145 ms 2872 KB Output is correct
15 Correct 225 ms 4308 KB Output is correct
16 Correct 209 ms 4140 KB Output is correct
17 Correct 241 ms 4460 KB Output is correct
18 Correct 213 ms 4436 KB Output is correct
19 Correct 241 ms 4436 KB Output is correct
20 Correct 206 ms 4436 KB Output is correct
21 Correct 222 ms 4468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 10 ms 1108 KB Output is correct
14 Correct 10 ms 980 KB Output is correct
15 Correct 7 ms 868 KB Output is correct
16 Correct 12 ms 1108 KB Output is correct
17 Correct 10 ms 1044 KB Output is correct
18 Correct 10 ms 1084 KB Output is correct
19 Correct 341 ms 4392 KB Output is correct
20 Correct 341 ms 4392 KB Output is correct
21 Correct 246 ms 4396 KB Output is correct
22 Correct 210 ms 4436 KB Output is correct
23 Correct 116 ms 2516 KB Output is correct
24 Correct 208 ms 4208 KB Output is correct
25 Correct 109 ms 2516 KB Output is correct
26 Correct 142 ms 3292 KB Output is correct
27 Correct 224 ms 4380 KB Output is correct
28 Correct 220 ms 4420 KB Output is correct
29 Correct 13 ms 1176 KB Output is correct
30 Correct 137 ms 3284 KB Output is correct
31 Correct 143 ms 2868 KB Output is correct
32 Correct 145 ms 2872 KB Output is correct
33 Correct 225 ms 4308 KB Output is correct
34 Correct 209 ms 4140 KB Output is correct
35 Correct 241 ms 4460 KB Output is correct
36 Correct 213 ms 4436 KB Output is correct
37 Correct 241 ms 4436 KB Output is correct
38 Correct 206 ms 4436 KB Output is correct
39 Correct 222 ms 4468 KB Output is correct
40 Correct 383 ms 5128 KB Output is correct
41 Incorrect 27 ms 980 KB Output isn't correct
42 Halted 0 ms 0 KB -