This page is still under construction.

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

Escape Route

Interview

Time limit1sMemory limit128 MB

Summary
Given your position and n-1 planet positions, find the closest planet, print both coordinates, and print the distance rounded to two decimals.
Level

Easy2 of 10

Topics
Brute force, Math, Implementation
Solved
No attempts yet

Problem

You are surrounded by Imperial warships and must land on a planet to escape. Your best chance is to reach the planet closest to your current location. Unfortunately, the navigation system has been damaged, so you must write a program that finds the planet nearest to your current position.

The distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is

dist=(x1−x2)2+(y1−y2)2dist = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}

Input

The first line contains a positive integer nn, the number of coordinate pairs. Each of the next nn lines contains two integers xx and yy separated by a space. The first pair is the coordinates of your current location; every pair after it is the coordinates of a planet you can escape to.

Output

Print three lines: the coordinates of your current location, the coordinates of the closest planet, and the distance to that planet rounded to two decimal places. If several planets are equally close, print the one that appears first in the input.

Examples3

  1. Example 1

    Input
    7
    5 4
    -80 9
    100 89
    67 -40
    10 20
    15 -5
    34 0
    
    Expected output
    5 4
    15 -5
    13.45
    
  2. Example 2

    Input
    2
    0 0
    3 4
    
    Expected output
    0 0
    3 4
    5.00
    
  3. Example 3

    Input
    3
    0 0
    1 0
    0 1
    
    Expected output
    0 0
    1 0
    1.00