Submission #825164

# Submission time Handle Problem Language Result Execution time Memory
825164 2023-08-14T14:55:46 Z drdilyor Lottery (CEOI18_lot) C++17
35 / 100
203 ms 4460 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<int> arr(n);
    for (int& i : arr) cin >> i;
    int q;
    cin >> q;
    vector<int> ask(q);
    for (int& i : ask) cin >> i;
    vector<int> rev(n+1, -1);
    {

        int k = 0;
        for (int i : ask) {
            rev[i] = k;
            k++;
        }
    }
    for (int i = n-1; i >= 0; i--) {
        if (rev[i] == -1)
            rev[i] = rev[i+1];
    }

    vector<array<int, 101>> cnt(n, {{}});
    for (int b = 1; b + m <= n; b++) {
        int al = 0, ar = m-1;
        int diff = 0;
        int bl = b, br = b + m-1;
        for (int i = 0; i < m; i++)
            diff += arr[al+i] != arr[bl+i];
        // cout << "[" << al << ".." << ar << "] and [" << bl << ".." << br << "] with " << diff << "\n";
        cnt[al][rev[diff]]++;
        cnt[bl][rev[diff]]++;
        while (br < n-1) {
            diff -= arr[al++] != arr[bl++];
            diff += arr[++ar] != arr[++br];
            // cout << "[" << al << ".." << ar << "] and [" << bl << ".." << br << "] with " << diff << "\n";
            cnt[al][rev[diff]]++;
            cnt[bl][rev[diff]]++;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= 100; j++)
            cnt[i][j] += cnt[i][j-1];
    }
    for (int k : ask) {
        for (int i = 0; i + m <= n; i++) {
            cout << cnt[i][rev[k]] << ' ';
        }
        cout << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 198 ms 4380 KB Output is correct
2 Correct 195 ms 4368 KB Output is correct
3 Correct 193 ms 4372 KB Output is correct
4 Correct 203 ms 4436 KB Output is correct
5 Correct 58 ms 4448 KB Output is correct
6 Correct 162 ms 4444 KB Output is correct
7 Correct 77 ms 4436 KB Output is correct
8 Correct 100 ms 4448 KB Output is correct
9 Correct 188 ms 4452 KB Output is correct
10 Correct 189 ms 4444 KB Output is correct
11 Correct 9 ms 1552 KB Output is correct
12 Correct 94 ms 4028 KB Output is correct
13 Correct 76 ms 4448 KB Output is correct
14 Correct 77 ms 4424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 198 ms 4380 KB Output is correct
2 Correct 195 ms 4368 KB Output is correct
3 Correct 193 ms 4372 KB Output is correct
4 Correct 203 ms 4436 KB Output is correct
5 Correct 58 ms 4448 KB Output is correct
6 Correct 162 ms 4444 KB Output is correct
7 Correct 77 ms 4436 KB Output is correct
8 Correct 100 ms 4448 KB Output is correct
9 Correct 188 ms 4452 KB Output is correct
10 Correct 189 ms 4444 KB Output is correct
11 Correct 9 ms 1552 KB Output is correct
12 Correct 94 ms 4028 KB Output is correct
13 Correct 76 ms 4448 KB Output is correct
14 Correct 77 ms 4424 KB Output is correct
15 Correct 186 ms 4372 KB Output is correct
16 Correct 159 ms 4448 KB Output is correct
17 Correct 195 ms 4456 KB Output is correct
18 Correct 194 ms 4456 KB Output is correct
19 Correct 187 ms 4452 KB Output is correct
20 Correct 188 ms 4460 KB Output is correct
21 Correct 193 ms 4448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -