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 main(){
int n, l;
cin >> n >> l;
int a[1 + n];
for(int i = 1; i <= n; i++){
cin >> a[i];
}
vector<vector<short> > A(n - l + 2, vector<short>(1 + l, 0));
for(int j = 1; j <= n - l; j++){
int curDiff =0 ;
for(int i = 0; i < l; i++){
if(a[1 + i] != a[j + 1 + i]){
curDiff++;
}
}
A[1][curDiff]++;
A[j + 1][curDiff]++;
for(int cur = 2; cur + j <= n - l + 1; cur++){
if(a[cur - 1] != a[cur - 1 + j]){
curDiff--;
}
if(a[cur + l - 1] != a[cur + l - 1 + j]){
curDiff++;
}
A[cur][curDiff]++;
A[j + cur][curDiff]++;
}
}
for(int i = 1; i <= n - l + 1; i++){
for(int j = 1; j <= l; j++){
A[i][j] += A[i][j - 1];
}
}
int q;
cin >> q;
while(q--){
int k;
cin >> k;
for(int i = 1; i <= n - l + 1; i++){
cout << A[i][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... |