//Agata Majewska 12.12.2022
#include <iostream>
//#include <string.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
int n,m,k;
int a,i,j;
int ile;
while(t>0){
cin>>n>>m>>k;
int tab[n];
for(i=0;i<n;i++){
tab[i]=m;
}
for(i=0;i<m*2;i++){
cin>>a;
tab[a-1]--;
}
ile=0;
j=0;
while((k>=j)&&(ile==0)){
for(i=0;i<n;i++){
if(tab[i]==j){
ile++;
}
//cout<<i+1<<": "<<tab[i]<<"\n";
}
k--;
j++;
}
if(ile>0){
cout<<j<<" "<<ile<<"\n";
k=j;
for(i=0;i<n;i++){
if(tab[i]==(j-1)){
if(k>=0){
cout<<i+1<<" ";
}
else{
cout<<i+1;
i=n;
}
k--;
}
}
}
else{
cout<<"-1";
}
t--;
if(t>0){
cout<<"\n";
}
}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | //Agata Majewska 12.12.2022 #include <iostream> //#include <string.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin>>t; int n,m,k; int a,i,j; int ile; while(t>0){ cin>>n>>m>>k; int tab[n]; for(i=0;i<n;i++){ tab[i]=m; } for(i=0;i<m*2;i++){ cin>>a; tab[a-1]--; } ile=0; j=0; while((k>=j)&&(ile==0)){ for(i=0;i<n;i++){ if(tab[i]==j){ ile++; } //cout<<i+1<<": "<<tab[i]<<"\n"; } k--; j++; } if(ile>0){ cout<<j<<" "<<ile<<"\n"; k=j; for(i=0;i<n;i++){ if(tab[i]==(j-1)){ if(k>=0){ cout<<i+1<<" "; } else{ cout<<i+1; i=n; } k--; } } } else{ cout<<"-1"; } t--; if(t>0){ cout<<"\n"; } } return 0; } |
English