Arctic Network
Time Limit: 2000MS |
|
Memory Limit: 65536K |
Total Submissions: 13108 |
|
Accepted: 4256 |
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
Source
Waterloo Local 2002.09.28 Test instructions: Two towns are connected in two ways, satellite and wireless technology, satellite connections do not cost, wireless technology is far more expensive, m towns have N satellites, seeking unlimited technology using maximum distance analysis: The largest K-side of the minimum spanning tree is obtained when n= =0 to a special sentence just do not understand why the same code g++ on the WA AC C + + on AC, Daniel explained Orz
#pragmaComment (linker, "/stack:1024000000,1024000000")#include<cstdio>#include<string>#include<iostream>#include<cstring>#include<cmath>#include<stack>#include<queue>#include<vector>#include<map>#include<stdlib.h>#include<algorithm>#defineLL __int64using namespacestd;Const intmaxn= ++5;intkase,n,m;Doubleans[maxn*maxn/2];intP[MAXN];structnode{Doublex, y;} PO[MAXN];structedge{intu,v; DoubleVal; BOOL operator< (ConstEdge A)Const { returnval<A.val; }}A[MAXN*maxn/2];DoubleCalc (node A,node B) {returnsqrt ((a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (a.y-b.y));}intFINDFA (intx) { returnp[x]==x?x:p[x]=Findfa (p[x]);}intMain () {//freopen ("In.txt", "R", stdin);scanf"%d",&Kase); while(kase--) {scanf ("%d%d",&n,&m); for(intI=1; i<=m;i++) scanf ("%LF%LF",&po[i].x,&po[i].y); intCnt=1; for(intI=1; i<=m;i++) { for(intj=1; j<=m;j++) {a[cnt].u=i; A[CNT].V=J; A[cnt++].val=Calc (po[i],po[j]); }} sort (a+1, A +1+CNT); for(intI=1; i<=m;i++) p[i]=i; intres=0; for(intI=1; i<=cnt;i++) { intu=a[i].u; intv=a[i].v; intx=FINDFA (U); inty=Findfa (v); if(x!=y) {p[x]=y; Ans[res++]=A[i].val; if(res==m-1) Break; } } if(n==0) printf ("%.2lf\n", ans[res-1]); Elseprintf"%.2lf\n", ans[res-n]); } return 0;}
View Code
POJ 2349 Arctic Network (minimum spanning tree K large (small) edge)