# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
856702 | ntkphong | Lottery (CEOI18_lot) | C++14 | 18 ms | 31780 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;
const int mxN = 2000 + 10;
int n, l, q;
int a[mxN];
int dp[mxN][mxN];
int prefix[mxN];
int answer[mxN][mxN];
int main() {
#define taskname ""
if(fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
cin >> n >> l;
if(n > 2000) return 0;
for(int i = 1; i <= n; i ++) cin >> a[i];
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= n; j ++) {
dp[i][j] = dp[i - 1][j - 1] + (a[i] != a[j]);
}
}
for(int i = l; i <= n; i ++) {
for(int j = l; j <= n; j ++) {
int x = dp[i][j] - dp[i - l][j - l];
prefix[x] ++ ;
}
answer[i - l + 1][0] = prefix[0];
for(int j = 1; j <= n; j ++) {
prefix[j] += prefix[j - 1];
answer[i - l + 1][j] = prefix[j];
}
for(int j = 0; j <= n; j ++)
prefix[j] = 0;
}
cin >> q;
while(q --) {
int k;
cin >> k;
for(int i = 1; i <= n - l + 1; i ++) {
cout << answer[i][k] - 1 << " ";
}
cout << "\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... |