kruskal算法。
#include#include #include #include using namespace std;const int maxn = 1000 + 10;const int maxm = 2000000 + 10;struct Point { int x,y;} a[maxn];struct Edge { int u,v,w;} g[maxm];int n,k,res,eid;int f[maxn];int find(int x) { return f[x]==x?x:f[x]=find(f[x]);}int sqr(int x) { return x*x;}int foo(Point a,Point b) { return sqr(a.x-b.x)+sqr(a.y-b.y); }void addedge(int a,int b,int c) { ++eid; g[eid].u=a; g[eid].v=b; g[eid].w=c; }bool cmp(Edge a,Edge b) { return a.w k) { f[ru]=rv; n--; } else break; } } printf("%.2lf\n",sqrt(g[res].w)); return 0; }