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()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int N,L; cin >> N >> L;
vector<int> arr(N); vector<vector<int>> dist(N,vector<int>(N+1,0));
for(int i = 0;i<N;++i) cin >> arr[i];
for(int i = 0;i<N-L+1;++i){
for(int j = i+1;j<N-L+1;++j){
int dis = 0;
for(int k = 0;k<L;++k){
if(arr[i+k] != arr[j+k]) ++dis;
}
++dist[i][dis]; ++dist[j][dis];
}
}
for(int i = 0;i<N;++i){
for(int j = 1;j<=N;++j) dist[i][j] += dist[i][j-1];
}
int Q; cin >> Q;
while(Q--){
int k; cin >> k;
for(int i = 0;i<N-L+1;++i){
if(i != N-L) cout << dist[i][k] << " ";
else cout << dist[i][k] << "\n";
}
}
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... |