# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155647 | karma | Lottery (CEOI18_lot) | C++14 | 1899 ms | 41364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define Task "test"
#define pb emplace_back
using namespace std;
const int N = int(1e4) + 1;
int f[N][N], pre[N], a[N];
int n, l, lim, q, k;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if(fopen(Task".inp", "r")) {
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
cin >> n >> l; lim = n - l + 1;
for(int i = 1; i <= n; ++i) cin >> a[i];
for(int j = 1; j <= lim; ++j) {
for(int i = 1; i <= n; ++i) {
if(i + j > n) break;
if(a[i] != a[i + j]) pre[i] = pre[i - 1] + 1;
else pre[i] = pre[i - 1];
}
for(int i = 0; i < lim; ++i) {
if(i + j + l > n) break;
++f[i + 1][pre[i + l] - pre[i]];
++f[i + j + 1][pre[i + l] - pre[i]];
}
}
for(int j = 0; j <= l; ++j) {
for(int i = 1; i <= lim; ++i) {
f[i][j] += f[i][j - 1];
//cout << f[i][j] << ' ';
}
//cout << '\n';
}
cin >> q;
while(q --) {
cin >> k;
for(int i = 1; i <= lim; ++i) cout << f[i][k] << ' ';
cout << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |