Submission #397652

#TimeUsernameProblemLanguageResultExecution timeMemory
397652VictorLottery (CEOI18_lot)C++17
0 / 100
222 ms500 KiB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;

const int INF = 1000000007;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);

    ushort n, l, q, mismatch[10000], ans[10000], groups;
    uint arr[10000];
    cin >> n >> l;
    groups = n - l + 1;

    rep(i, 0, n) cin >> arr[i];

    cin >> q;
    while (q--) {
        ushort diff;
        cin >> diff;
        memset(ans, 0, sizeof(ans));
        memset(mismatch, 0, sizeof(mismatch));

        rep(i, 0, l) rep(j, i + 1, groups + i) if (arr[i] != arr[j])++ mismatch[j - i];

        rep(i, 0, groups) {

            rep(j, i + 1, groups) {
                if (mismatch[j] <= diff) {
                    ++ans[i];
                    ++ans[j];
                }
            }

            rep(j, i + 1, groups + i) if (arr[i] != arr[j])-- mismatch[j - i];
            rep(j, i + l + 1, n) if (arr[i + l] != arr[j])++ mismatch[j - i - l];
            per(j,1,groups)mismatch[j]=mismatch[j-1];
        }

        rep(i, 0, groups) cout << ans[i] << ' ';
        cout << endl;
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...