Frogger
| Time limit:1000 ms |
|
Memory limit:65536 K |
| Total submissions:26435 |
|
Accepted:8603 |
Description
Freddy Frog is sitting on a stone in the middle of a lake. suddenly he notices Fiona frog who is sitting on another stone. he plans to visit her, but since the water is dirty and full of tourists 'sunscreen, he wants to avoid login Ming and instead reach her by jumping.
Unfortunately Fiona's Stone is out of his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach her by a sequence of several small jumps.
To execute a given sequence of jumps, a frog's jump range obviously must be at least as long as the longest jump occuring in the sequence.
The frog distance (humans also call it Minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.
You are 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 will contain in one or more test cases. the first line of each test case will contain the number of stones N (2 <= n <= 200 ). the next n lines each contain two integers Xi, Yi (0 <= xi, Yi <= 1000) representing the coordinates of stone # I. stone #1 is Freddy's stone, stone #2 is Fiona's stone, the other N-2 stones are 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 is replaced by the test case number (they are numbered from 1) and y is replaced 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 0
3 4317 419 418 50Sample output
Scenario #1Frog Distance = 5.000Scenario #2Frog Distance = 1.414
Q: Actually, it's just that brother Tao, a frog from Stone 0, looks at Miss Yin, a frog from stone 1. Then he wants to find Miss Yin, but he can't do anything if there is too much garbage in the lake, clever brother Tao thought of a good way to find another stone as the transfer station in the past, ask brother Tao to jump to Miss Yin in the Process of the shortest path of the maximum step of the minimum length.
PS: it takes a long time to understand what it means. Very internal injury. Maybe you still don't understand this yet. Please check it out. It's really bad.
# Include <stdio. h> # include <string. h> # include <math. h> # include <stdlib. h ># include <algorithm> using namespace STD; struct node {Double X, Y;} edge [1010]; double map [1010] [1010]; double distan (struct node A, struct Node B) {return SQRT (. x-b.x) * (. x-b.x) +. y-b.y) * (. y-b.y);} int N, I, J, K; void Floyd () {for (k = 0; k <n; k ++) for (I = 0; I <n; I ++) for (j = 0; j <n; j ++) {map [I] [J] = min (Map [I] [J], max (Map [I] [K], map [k] [J]); // The most important thing is also the deformation.} int main () {int CNT = 1; while (~ Scanf ("% d", & N) {If (n = 0) break; for (I = 0; I <n; I ++) scanf ("% lf", & edge [I]. x, & edge [I]. y); for (I = 0; I <n; I ++) for (j = 0; j <n; j ++) map [I] [J] = distan (edge [I], edge [J]); Floyd (); printf ("Scenario # % d \ n ", CNT ++); printf ("frog distance = %. 3lf \ n ", map [0] [1]);} return 0 ;}
Zookeeper
Frogger (Shortest _ Floyd deformation)