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 k_N = 1e4 + 3;
int n, l;
int a[k_N];
short cnt[k_N][k_N];
short prefix[k_N];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> l;
for(int i = 0; i < n; ++i)
cin >> a[i];
int q;
cin >> q;
for(int d = 1; d < n - l + 1; d++){
prefix[0] = (a[0] != a[d]);
for(int i = 1; i < n - d; ++i)
prefix[i] = (a[i] != a[i + d]) + prefix[i - 1];
for(int i = 0; i < n - l + 1 - d; ++i){
int sum = prefix[i + l - 1];
if(i)
sum -= prefix[i - 1];
cnt[i][sum]++;
cnt[i + d][sum]++;
}
}
for(int i = 0; i < n; ++i)
for(int j = 1; j < n; ++j)
cnt[i][j] += cnt[i][j - 1];
for(int i = 0; i < q; ++i){
int k;
cin >> k;
for(int j = 0; j < n - l + 1; ++j)
cout << cnt[j][k] << " ";
cout << "\n";
}
}
# | 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... |