Original title Link: http://poj.org/problem?id=2253
Frogger
Time Limit: 1000MS |
|
Memory Limit: 65536K |
Total Submissions: 30637 |
|
Accepted: 9883 |
Description
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who was sitting on another stone. He plans to visit she, but since the water was dirty and full of tourists ' sunscreen, he wants to avoid swimming and instea D reach her by jumping.
Unfortunately Fiona ' s stone is out of the his 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 both stones therefore is defined as the minimum necessary Jump range possible paths between the stones.
You is given the coordinates of Freddy ' s stone, Fiona ' s stone and all other stones in the lake. Your job is to 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 all test case would contain the number of stones N (2<=n<=200). The next n lines each contain the integers xi,yi (0 <= xi,yi <=) representing the coordinates of stone #i. ston E #1 is Freddy's stone, stone #2 is Fiona's Stone, the other n-2 stones was unoccupied. There ' s a blank line following each 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" where x was replaced by the TES The T Case number (they was numbered from 1) and Y was replaced by the appropriate real number, printed to three decimals. Put a blank line after all test case, even after the last one.
Sample Input
20 03 4317 419 418 50
Sample Output
Scenario #1Frog Distance = 5.000Scenario #2Frog Distance = 1.414
Source
ULM Local 1997 Test Instructions
A frog is going to jump from one stone to another and tell you the coordinates of the stone to find the smallest jumping range. The jump range is defined as the longest jump in any feasible path.
Exercises
Transformation Floyd,floyd is the idea of DP, then we can define, Dp[i][j] represents the minimum jump range from I to J, then Dp[i][j]=min (Dp[i][j],max (Dp[i][k],dp[k][j]))
Code
#include <iostream>#include<queue>#include<cstring>#include<cstdio>#include<algorithm>#include<cmath>#defineINF 1008611#defineMax_n 234using namespacestd;DoubleF[max_n][max_n];DoubleX[max_n],y[max_n];intN;intcas=0;intMain () { while(true) {scanf ("%d", &N); if(n = =0) Break; for(inti =0; I < n; i++) cin >> X[i] >>Y[i]; for(inti =0; I < n; i++) {F[i][i]=0; for(intj =0; J < N; J + +) F[i][j]= F[j][i] = sqrt (POW (x[i]-x[j],2.0) + POW (y[i]-y[j],2.0)); } for(intK =0; K < n; k++) for(intj =0; J < N; J + +) for(inti =0; I < n; i++) F[i][j]=min (f[i][j], Max (F[i][k], f[k][j])); printf ("Scenario #%d\nfrog Distance =%.3lf\n\n", ++cas, f[0][1]); } return 0;}
POJ 2253 Frogger Floyd