# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217522 | DystoriaX | Lottery (CEOI18_lot) | C++14 | 816 ms | 8464 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>
using namespace std;
int n, l;
int a[10010], b[10010];
int cnt[110][10010];
int q, qr[110];
int nxt[10010];
vector<int> cmp;
int main(){
scanf("%d%d", &n, &l);
for(int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
scanf("%d", &q);
for(int i = 1; i <= q; i++){
scanf("%d", &qr[i]);
cmp.emplace_back(qr[i]);
}
sort(cmp.begin(), cmp.end());
int idx = 0;
for(int i = 0; i <= n; i++){
while(idx < q && cmp[idx] < i) idx++;
nxt[i] = idx;
}
for(int d = 1; d < n - l + 1; d++){
int diff = 0;
for(int j = 1; j <= l; j++){
if(a[j] != a[j + d]) diff++;
}
cnt[nxt[diff]][1]++;
cnt[nxt[diff]][d + 1]++;
for(int i = 2; i + l + d - 1 <= n; i++){
if(a[i - 1] != a[i + d - 1]) diff--;
if(a[i + l - 1] != a[i + l - 1 + d]) diff++;
// cout << "Comparing " << i + l - 1 << " with " << i + l + d -
cnt[nxt[diff]][i]++;
cnt[nxt[diff]][i + d]++;
}
}
for(int i = 1; i <= n; i++){
for(int k = 1; k <= q; k++)
cnt[k][i] += cnt[k - 1][i];
}
for(int i = 1; i <= q; i++){
for(int j = 1; j <= n - l + 1; j++){
printf("%d ", cnt[nxt[qr[i]]][j]);
}
printf("\n");
}
return 0;
}
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... |