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;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'
const int MXN = 1e4;
int freq[MXN+1][MXN+2];
int main() {
#ifdef shiven
freopen("test.in", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, l; cin >> n >> l;
vi nums(n);
for_(i, 0, n) cin >> nums[i];
for_(d, 1, n+1) {
vi temp(n);
for_(j, d, n) if (nums[j] != nums[j-d]) temp[j] += 1;
for_(i, d, n) temp[i] += temp[i-1];
for_(j, d, n-l+1) {
int dist = temp[j+l-1] - (j > 0 ? temp[j-1] : 0);
freq[j][dist] += 1; freq[j-d][dist] += 1;
}
}
for_(i, 0, n) for_(j, 1, n+1) freq[i][j] += freq[i][j-1];
int q; cin >> q;
while (q--) {
int k; cin >> k;
for_(i, 0, n-l+1) cout << freq[i][k] << " ";
cout << endl;
}
return 0;
}
# | 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... |