This page is still under construction.

Parts of this page are still being built. What you see may change.

Frogger

Interview

Time limit1sMemory limit128 MB

Summary
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 nn. Each of the following nn lines contains two integers xix_i and yiy_i, the coordinates of a stone. Stone #1 is Freddy's stone, stone #2 is Fiona's stone, and the remaining n−2n-2 stones are empty stones. A blank line separates consecutive test cases. The input ends when nn equals 00.

Output

For each test case, print two lines: Scenario #x on the first line and Frog Distance = y on the second, where xx is the test case number (starting from 1) and yy is the frog distance rounded to three decimal places. Print a blank line between the outputs of consecutive test cases.

Examples1

  1. Example 1

    Input
    2
    0 0
    3 4
    
    3
    17 4
    19 4
    18 5
    
    0
    
    Expected output
    Scenario #1
    Frog Distance = 5.000
    
    Scenario #2
    Frog Distance = 1.414