제출 #607523

#제출 시각아이디문제언어결과실행 시간메모리
607523PietraLottery (CEOI18_lot)C++14
45 / 100
553 ms65536 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...