本文共 941 字,大约阅读时间需要 3 分钟。
1 /* 2 10034 - Freckles 3 克鲁斯克尔最小生成树!~ 4 */ 5 #include6 #include 7 #include 8 #include 9 using namespace std;10 11 struct node{12 double x, y;13 };14 15 struct tree{16 int u, v;17 double d;18 };19 20 node nd[105];21 int f[105];22 tree tt[5010];23 24 bool cmp(tree a, tree b){25 return a.d < b.d;26 }27 28 int getFather(int x){29 return x==f[x] ? x : f[x]=getFather(f[x]);30 }31 32 int Union(int a, int b){33 int fa=getFather(a), fb=getFather(b);34 if(fa!=fb){35 f[fa]=fb;36 return 1;37 }38 return 0;39 } 40 41 int main(){42 int t;43 cin>>t;44 while(t--){45 int n;46 cin>>n;47 for(int i=1; i<=n; ++i){48 cin>>nd[i].x>>nd[i].y;49 f[i]=i;50 }51 int cnt=0;52 for(int i=1; i