#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string.h>
using namespace std;
const int N = 505 ,M = N * N ;
struct point{
int x,y;
}star[N];
struct node{
int a,b;
double w;
}edge[M];
int n,m,bian;
int p[N];
int find(int x) {
return p[x] == x ? x : (p[x] = find(p[x]));
}
bool cmp(node a,node b){
return a.w < b.w;
}
double kruscal(){
int cnt = m;
double ans = 0;
for(int i = 1;i <= m;i ++) p[i] = i;
sort(edge + 1,edge + bian + 1,cmp);
for(int i = 1;i <= bian;i ++){
if(cnt <= n) return ans; // return edge[i-1].w
int a = edge[i].a,b = edge[i].b;
int fa = find(a),fb = find(b);
if(fa != fb){
p[fa] = fb;
cnt --;
ans = edge[i].w;
}
}
// return ans; 加上就对,不加上就错. ???
}
double dis(int x1,int y1,int x2,int y2){
double dx = (x1 - x2);
double dy = (y1 - y2);
return sqrt(dx * dx + dy * dy);
}
int main(){
int t;
scanf("%d",&t);
//mem
for(int i=1;i<=t;i++){
memset(edge,0,sizeof edge);
scanf("%d%d",&n,&m);
bian = 1;
for(int j = 1;j <= m; j++){
int x,y;
double c;
scanf("%d%d",&x,&y);
star[j].x = x, star[j].y = y;
for(int k = j-1; k > 0 ; k--){
c = dis(x,y,star[k].x,star[k].y);
edge[bian].a = j, edge[bian].b = k, edge[bian].w = c;
bian++;
//edge[bian ++] = {j,k,c};
}
}
bian--;
double ans = kruscal();
printf("%.2f\n", ans);
}
return 0;
}
有点疑问的打卡