Submission #807035

# Submission time Handle Problem Language Result Execution time Memory
807035 2023-08-04T12:34:21 Z Valaki2 Lottery (CEOI18_lot) C++14
35 / 100
334 ms 4488 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back

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;
    bool zero = false;
    for(int i = 1; i <= q; i++) {
        cin >> qry[i];
        conv[qry[i]] = i;
    }
    for(int i = n - 1; i >= 0; i--) {
        if(conv[i] == 0) {
            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++) {
            ans[i][j + 1] += ans[i][j];
        }
    }
    for(int i = 1; i <= q; i++) {
        for(int j = 1; j <= n - l + 1; j++) {
            cout << ans[j][i] << " ";
        }
        cout << "\n";
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Compilation message

lot.cpp: In function 'void solve()':
lot.cpp:23:10: warning: unused variable 'zero' [-Wunused-variable]
   23 |     bool zero = false;
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 334 ms 4376 KB Output is correct
2 Correct 334 ms 4396 KB Output is correct
3 Correct 235 ms 4396 KB Output is correct
4 Correct 223 ms 4396 KB Output is correct
5 Correct 107 ms 2516 KB Output is correct
6 Correct 206 ms 4200 KB Output is correct
7 Correct 103 ms 2516 KB Output is correct
8 Correct 144 ms 3288 KB Output is correct
9 Correct 228 ms 4344 KB Output is correct
10 Correct 201 ms 4400 KB Output is correct
11 Correct 13 ms 1108 KB Output is correct
12 Correct 137 ms 3260 KB Output is correct
13 Correct 145 ms 2976 KB Output is correct
14 Correct 134 ms 2864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 4376 KB Output is correct
2 Correct 334 ms 4396 KB Output is correct
3 Correct 235 ms 4396 KB Output is correct
4 Correct 223 ms 4396 KB Output is correct
5 Correct 107 ms 2516 KB Output is correct
6 Correct 206 ms 4200 KB Output is correct
7 Correct 103 ms 2516 KB Output is correct
8 Correct 144 ms 3288 KB Output is correct
9 Correct 228 ms 4344 KB Output is correct
10 Correct 201 ms 4400 KB Output is correct
11 Correct 13 ms 1108 KB Output is correct
12 Correct 137 ms 3260 KB Output is correct
13 Correct 145 ms 2976 KB Output is correct
14 Correct 134 ms 2864 KB Output is correct
15 Correct 247 ms 4272 KB Output is correct
16 Correct 226 ms 4084 KB Output is correct
17 Correct 218 ms 4488 KB Output is correct
18 Correct 200 ms 4444 KB Output is correct
19 Correct 223 ms 4436 KB Output is correct
20 Correct 207 ms 4444 KB Output is correct
21 Correct 209 ms 4456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -