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 maxn = 1e4 + 5 ;
int n, l, v[maxn], dist[maxn][maxn], k, q ;
void solve(){
for(int i = 1 ; i <= n ; i++){
for(int j = 1 ; j <= n ; j++){ // dist de i p j
if(i == j || i + l - 1 > n || j + l - 1 > n) continue ;
int ctr = 0 ;
for(int k = 0 ; k < l ; k++) if(v[i+k] != v[j+k]) ctr++ ;
dist[i][j] = dist[j][i] = ctr ;
}
}
}
int main(){
ios_base::sync_with_stdio(false) ; cin.tie(NULL) ;
cin >> n >> l ;
for(int i = 1 ; i <= n ; i++) cin >> v[i] ;
solve() ;
// for(int i = 1 ; i <= n ; i++){
// for(int j = 1 ; j <= n ; j++){
// cout << dist[i][j] <<" " ;
// }
// cout << "\n" ;
// }
cin >> q ;
for(int i = 1 ; i <= q ; i++){
cin >> k ;
for(int i = 1 ; i + l - 1 <= n ; i++){
int ct = 0 ;
for(int j = 1 ; j + l - 1 <= n ; j++) if(i != j && dist[i][j] <= k) ct++ ;
cout << ct << " " ;
}
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... |