Frogger
InterviewTime limit1sMemory limit128 MB
Given n points, find the path from point 1 to point 2 that minimizes the longest edge, and report that minimized maximum edge length.
- Level
Medium6 of 10
- Topics
- Graph, Shortest path, Greedy, Math
- Solved
- No attempts yet
Problem
Freddy the frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona the frog, who is sitting on another stone, and he decides to visit her. Because the water is dirty and full of tourists' sunscreen, he wants to reach her by jumping from stone to stone instead of swimming.
Unfortunately Fiona's stone is too far away to reach in a single jump, so Freddy plans to use other stones as intermediate stops and reach her in several jumps.
To follow a given sequence of jumps, a frog's jumping ability (the greatest distance it can cover in one jump) must be at least as large as the longest single jump in that sequence.
The frog distance between two stones is defined as follows. Over all possible paths from one stone to the other, take the length of the longest jump on a path (call it the cost of that path); the frog distance is the minimum such cost over all paths.
You are given the coordinates of Freddy's stone, Fiona's stone, and every other stone in the lake. Compute the frog distance between Freddy's stone and Fiona's stone.
Input
The input consists of one or more test cases. The first line of each test case contains the number of stones . Each of the following lines contains two integers and , the coordinates of a stone. Stone #1 is Freddy's stone, stone #2 is Fiona's stone, and the remaining stones are empty stones. A blank line separates consecutive test cases. The input ends when equals .
Output
For each test case, print two lines: Scenario #x on the first line and Frog Distance = y on the second, where is the test case number (starting from 1) and is the frog distance rounded to three decimal places. Print a blank line between the outputs of consecutive test cases.