1#include <iostream>2#include <cmath>3#include <algorithm>4#include <cstdio>5 using namespacestd;6 #defineMAXN 6007 intPAR[MAXN];8 intPos;9 intn,cnt,m;Ten DoubleLen; One DoubleTT[MAXN];//the path of the saved selection A structnode - { - intx; the inty; - DoubleW; - }; -Node E[MAXN * (MAXN-1) /2]; + intcmpConstNode &a,ConstNode &b) - { + returnA.W <B.W; A }; at structP - { - intx; - inty; - } PO[MAXN]; - voidInit () in { - for(inti =0; I <= n+5; i++) toPar[i] =i; +pos =0; -Len =0.0; theCNT =0; * } $ intFind (intx)Panax Notoginseng { - intK,j,r; theR =x; + while(Par[r]! =R) AR =Par[r]; theK =x; + while(k! =R) - { $j =Par[k]; $PAR[K] =R; -K =J; - } the returnR; - }Wuyi intMerge (intXinty) the { - intA =Find (x); Wu intb =Find (y); - if(A! =b) About { $Par[a] =Par[b]; - return 1; - } - return 0; A } + voidinput () the { - intu,v; $ for(inti =1; I <= N; i++) thescanf"%d%d",&po[i].x,&po[i].y); the } the the voidMake () - { in init (); the DoubleDist; the for(inti =1; I < n; i++) About { the for(intj = i +1; J <= N; J + +) the { theDist = (po[i].x-po[j].x) * (po[i].x-po[j].x) + (PO[I].Y-PO[J].Y) * (PO[I].Y-po[j].y); +e[pos].x =i; -E[POS].Y =J; theE[POS].W =sqrt (dist);Bayipos++; the } the } -Sort (e,e+pos,cmp); - for(inti =0; I < POS; i++) the { the if(Merge (E[I].X,E[I].Y)) the { theTT[CNT] =E[I].W; -cnt++; the } the if(cnt = = N-1) Break; the }94 } the intMain () the { theFreopen ("Input.txt","R", stdin);98 intT; Aboutscanf"%d",&t); - while(t--)101 {102scanf"%d%d",&m,&n);103 input ();104 Make (); theprintf"%.2lf\n", tt[cnt-m]);106 }107 108 return 0;109}