The main topic, there are two frogs, respectively, on two stones, frog a want to go to the Frog B, he can jump directly to the B stone, you can jump to other stones, and then jump from other stones to B there, the frog from A to B in all the path of the smallest frog Distance, we define Frog Distance is the largest edge of a path from A to B
If point 0 points 1 there are 3 roads
The first path passes through 2 points, 3 edges of the value 1 4 3
Second Path one side 5
Third Route 1 3 2
Then the Frog Distance is 4 5 3 respectively and the final output is 3.
Sample Input
2
0 0
3 4
3
17 4
19 4
18 5
0
Sample Output
Scenario #1
Frog Distance = 5.000
Scenario #2
Frog Distance = 1.414
1# include <iostream>2# include <cstdio>3# include <cstring>4# include <algorithm>5# include <cmath>6# define LLLong Long7 using namespacestd;8 9 Const intmaxn= -;Ten Const Doubleinf=0x3f3f3f3f; One intN; A BOOLVIS[MAXN]; - DoubleCOST[MAXN][MAXN]; - DoubleLOWCOST[MAXN];//holds the weight of the smallest edge in the largest edge of all paths from the starting point to the I point the - struct Point - { - intx; + inty; - }P[MAXN]; + A voidDijkstra (intBeg) at { - for(intI=0; i<n;i++) - { -lowcost[i]=inf;vis[i]=false; - } -lowcost[beg]=0; in for(intj=0; j<n;j++) - { to intk=-1; + Doublemin=INF; - for(intI=0; i<n;i++) the if(!vis[i]&&lowcost[i]<Min) * { $min=Lowcost[i];Panax Notoginsengk=i; - } the if(k==-1) + Break ; Avis[k]=true; the for(intI=0; i<n;i++) + if(!vis[i]&&max (Lowcost[k],cost[k][i]) <Lowcost[i]) - { $lowcost[i]=Max (lowcost[k],cost[k][i]); $ } - } - the } - Wuyi DoubleDis (point a,point B) the { - returnsqrt ((Double) (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (a.y-b.y)); Wu } - About intMain () $ { - //freopen ("In.txt", "R", stdin); - intIcase =0 ; - while(SCANF ("%d", &N), N) A { +icase++ ; the intu, V, W; - intI, J; $ for(i =0; I < n; i++) thescanf"%d%d", &p[i].x, &p[i].y); the the for(i =0; I < n; i++) the for(j =0; J < N; J + +) - { in if(i = =j) theCOST[I][J] =0 ; the Else AboutCOST[I][J] =dis (p[i],p[j]); the } theDijkstra (0) ; theprintf"Scenario #%d\nfrog Distance =", icase); +printf"%.3lf\n\n", lowcost[1]); - the }Bayi the return 0 ; the}
View Code
POJ the largest edge in 22,531 paths and find the smallest one.