Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
0
Indexable
Never
#include<iostream>
using namespace std ;
int n  ,k  , m  ;
int con[18];
int biphat[18];
bool kiemtra(){
	for(int i  =0 ; i  <= n -k ;i ++){
		biphat[i] = 0 ;
	}
	for(int i  =0  ; i <= n -k ; i ++){
		int maxx = con[i + k -1];
		int dem = 0 ;
		for(int j = i ; j <= i+ k -1 ; j ++ ){
			if(maxx < con[j] ){
				maxx = con[j] ;
				dem = 1 ;
			}
			if(maxx == con[j] ){
				dem ++ ;
			}
		}
		if(dem == k) biphat[i]++ ;
	}
	//for(int i  =0 ; i  <= n -k ;i ++){
	//	cout<<biphat[i]<<" ";
	//}
	//cout<<"/////"<<endl;
	for(int i  =0 ; i  <= n -k ;i ++){
		if(biphat[i] == 1) return true;
	}
	return false;
}
int main(){
	//freopen("Text.txt" ,"r" , stdin);
	int t ;
	cin >>t ;
	for(int tc = 1 ; tc <= t ; tc ++){
		cin >>n>>k>>m;
		cout<<"#"<<tc<<" ";
		if(m == 1){
			cout<<-1<<endl;
			continue ;
		}
		for(int i  = 0 ; i < n ; i ++){
			cin >> con[i] ; // nong do con cua con 
		}
		bool flag = false;
		if(!kiemtra()){
			cout<<0<<endl;
			continue;
		}
		else{
			for(int i  = 0 ; i < n ; i ++){
				con[i] += 1 ;
				if(!kiemtra()){
					flag = true ;
					break ;
				}
				con[i] -= 1;
			}
		}
		if(flag) cout<<1<<endl;
	}
	return 0 ;
}