Title Link: http://poj.org/problem?id=2253
DescriptionFreddy Frog isSitting on a stoneinchThe middle of a lake. Suddenly he notices Fiona Frog who isSitting on another stone. He plans to visit she, but since the water isDirty and full of tourists'sunscreen, he wants to avoid swimming and instead reach she by jumping.Unfortunately Fiona'S stone is out of its jump range. Therefore Freddy considers to use other stones as intermediate stops and reach hers by a sequence of several small jumps.
To execute a given sequence of jumps, a frog's jump range obviously must is at least as long as the longest jump occuring in the sequence.The frog distance (humans also call it minimax distance) between the Stones therefore isDefined asThe minimum necessary jump range through all possible paths between the stones. you are given the coordinates of Freddy's Stone, Fiona'S stone and all other stonesinchThe lake. Your Job isTo compute the frog distance between Freddy's and Fiona's Stone. Input The input would contain one or more test cases. the first line of each test CaseWould contain the number of stones N (2<=n<= $). The next n lines each contain the integers xi,yi (0<= Xi,yi <= +) representing the coordinates of Stone #i. Stone #1 isFreddy's Stone, stone #2 is Fiona'S Stone, the other n-2Stones is unoccupied. There's a blank line following all test case. Input is terminated by a value of zero (0) for N. Output for each test Case, print a line saying"Scenario #x"and a line saying"Frog Distance = y" whereX isReplaced by the test CaseNumber (They is numbered from 1) and Y isReplaced by the appropriate real number, printed to three decimals. Put a blank line after each test Case, even after the last one. Sample Input 20 03 43 - 4 + 4 - 50 Sample OutputScenario #1Frog Distance=5.000Scenario #2Frog Distance=1.414 SourceUlm Local1997
A frog thought of another frog, but not once, he needs to use the middle of the stone jump, ask him to the other one that goes the shortest distance in the longest jump is how much?
Method: Find the maximum distance from the smallest spanning tree where the other frog is located.
1#include <stdio.h>2#include <cstring>3#include <cstdlib>4#include <algorithm>5#include <math.h>6#include <queue>7 using namespacestd;8 #defineINF 0x3f3f3f3f9 #definell Long LongTen #defineMet (b) memset (A,b,sizeof (a)) One #defineN 500 A structnode - { - intx, y; the - }s[n]; - intMap[n][n]; - intDis[n],ans; + intVis[n]; - voidDij (intN) + { AMet (Vis,0); at for(intI=1; i<=n;i++) -dis[i]=map[1][i]; -vis[1]=1; - for(intI=1; i<n;i++) - { - intan=INF; in intk=-1; - for(intj=1; j<=n;j++) to { + if(!vis[j] && an>Dis[j]) -an=dis[k=j]; the } *ans=Max (Ans,an); $ if(k==2)///when k==2 has reached the coordinates of another frogPanax Notoginseng return ; -vis[k]=1; the for(intj=1; j<=n;j++) + { A if(!Vis[j]) thedis[j]=min (dis[j],map[k][j]); + } - $ } $ } - intMain () - { the intN; - intcon=1;Wuyi while(SCANF ("%d",&N), N) the { - for(intI=0; i<=n;i++) Wu { - for(intj=0; j<=n;j++) AboutMap[i][j]=i==j?0: INF; $ } - for(intI=1; i<=n;i++) - { -scanf"%d%d",&s[i].x,&s[i].y); A } + for(intI=1; i<=n;i++) the { - for(intj=i;j<=n;j++) $ { the intans= (s[i].x-s[j].x) * (s[i].x-s[j].x) + (S[I].Y-S[J].Y) * (s[i].y-s[j].y); themap[i][j]=map[j][i]=ans; the } the } -ans=-INF; in Dij (n); theprintf"Scenario #%d\n", con++); theprintf"Frog Distance =%.3f\n\n", sqrt (ans)); About } the return 0; the}
(POJ 2253) The largest section of Frogger shortest way