# HDU 1875 Kruscal

``````#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
struct Island
{
int x,y;
};
struct node
{
int u,v;
double w;
};
Island arr[220];
node  edge[20000];
int per[220];
int n;
bool cmp(node a,node b)
{
return a.w<b.w;
}
void init()
{
for(int i=1;i<=n;  i)
{
per[i]=i;
}
}
int find(int x)
{
if(x==per[x]) return x;
return per[x]=find(per[x]);
}
bool join(int x,int y)
{
int fx=find(x);
int fy=find(y);
if(fx!=fy)
{
per[fx]=fy;
return 1;
}
return 0;
}
int main()
{
int T;
int i,j,k;
double x,y;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
init();
for(i=1;i<=n;  i)
{
scanf("%d%d",&arr[i].x,&arr[i].y);
}
//m=n*(n-1)/2;
k=0;
for(i=1;i<=n;  i)//把所有路記錄在node結構體中
{
for(j=i 1;j<=n;  j)
{
edge[k].u=i;
edge[k].v=j;
x=(arr[j].y-arr[i].y)*(arr[j].y-arr[i].y);
y=(arr[j].x-arr[i].x)*(arr[j].x-arr[i].x);
double temp=sqrt(x y);
edge[k  ].w=temp;
}
}
sort(edge,edge k,cmp);
double sum=0;
for(i=0;i<k;  i)
{
if(edge[i].w<=1000&&edge[i].w>=10&&join(edge[i].u,edge[i].v))
{
sum =edge[i].w;
}
}
int cnt=0;
bool flag=0;
for(i=1;i<=n;  i)
{
if(i==per[i]) cnt  ;
if(cnt>1)
{
flag=1;
break;
}
}
if(flag) printf("oh!\n");
else
printf("%.1lf\n",sum*100);
}
return 0;
}``````