Title Link: http://poj.org/problem?id=2349
Description
The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Different communication technologies is to being used in establishing the Network:every outpost would have a radio trans Ceiver and some outposts would in addition has a satellite channel.
Any-outposts with a satellite channel can communicate via the satellite, regardless of their location. Otherwise, outposts can communicate by radio only if the distance between them does not exceed D, which depends of the Power of the transceivers. Higher power yields higher D but costs more. Due to purchasing and maintenance considerations, the transceivers at the outposts must is identical; That's, the value of D is the same for every pair of outposts.
Your job is to determine the minimum D required for the transceivers. There must is at least one communication path (direct or indirect) between every pair of outposts.
Input
The first line of input contains N, the number of test cases. The first line of all test case contains 1 <= s <=, the number of satellite channels, and S < P <=, t He number of outposts. P lines follow, giving the (x, y) coordinates of each outpost in km (coordinates is integers between 0 and 10,000).
Output
For each case, output should consist of a single line giving the minimum D required to connect the network. Output should is specified to 2 decimal points.
Sample Input
12 40 1000 3000 600150 750
Sample Output
212.13
1 /*2 problem3 the topic understanding has certain difficulty, understood is the water question together. How do you understand it? is to read it over and over again. 4 It is important that each vertex is equipped with a wireless receiver, and some of the vertices will also be equipped with a satellite channel. Now give the number of satellite channels and vertex5 number, and the coordinates of each vertex, calculates and outputs how much of the edge of the first size of the smallest spanning tree6 7 Thinking of solving problems8 at the beginning of the reading, thought to eliminate the S-edge, the results of the sample calculation is 200, in fact, the number of satellite channels, in exchange for each of the two satellite channels9 to eliminate an edge. Ten process the edges between each of the two points, using the Kruskal algorithm to join one line, until the smallest spanning tree is formed, then the number S edge. One */ A#include <cstdio> -#include <math.h> -#include <algorithm> the - using namespacestd; - structnode{ - intx, y; +}node[1010]; - + structedge{ A intu,v; at DoubleW; -}edge[300010]; - intcmpstructEDGE A,structEDGE B) { - returna.w<B.W; - } - intf[1010]; in intMergeintVintu); - intGETF (intv); to intMain () + { - intt,s,p,i,j,k; thescanf"%d",&t); * while(t--) $ {Panax Notoginsengscanf"%d%d",&s,&p); - for(i=1; i<=p;i++){ thescanf"%d%d",&node[i].x,&node[i].y); + } A thek=0; + for(i=1; i<=p-1; i++){ - for(j=i+1; j<=p;j++){ $edge[k].u=i; $edge[k].v=J; -EDGE[K].W=SQRT (1.0* (node[i].x-node[j].x) * (node[i].x-node[j].x) + - 1.0* (NODE[I].Y-NODE[J].Y) * (node[i].y-node[j].y)); the //printf ("%lf\n", EDGE[K].W); - }Wuyi } theSort (edge,edge+k,cmp); - Wu /*For (i=0;i<k;i++) - printf ("%lf\n", EDGE[I].W);*/ About $ for(i=1; i<=p;i++) -f[i]=i; - - intcou=0; A for(i=0; i<k;i++){ + if(merge (EDGE[I].U,EDGE[I].V)) { the //printf ("Selected%d of this edge%.2lf\n", I,EDGE[I].W); -cou++; $ } the if(Cou = = Ps) { theprintf"%.2lf\n", EDGE[I].W); the Break; the } - } in } the return 0; the } About the intGETF (intv) the { the returnf[v]==v?v:f[v]=GETF (F[v]); + } - the intMergeintVintu)Bayi { the intt1,t2; thet1=GETF (v); -T2=getf (u); - if(T1! =T2) { thef[t2]=T1; the return 1; the } the return 0; -}
POJ 2349 Arctic Network (Edge of section s in the smallest spanning tree)