This page is still under construction.

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

Dog & Gopher

Time limit1sMemory limit128 MB

Summary
Given the gopher's position, the dog's position, and a list of holes, find the first hole the gopher reaches no later than the dog.
Level

Easy2 of 10

Topics
Implementation, Geometry
Solved
No attempts yet

Problem

A large field contains a dog and a gopher. The dog wants to eat the gopher, while the gopher wants to reach safety through one of several gopher holes dug in the field.

Neither animal is a mathematician, but neither is foolish either. The gopher picks one hole and runs toward it in a straight line at a fixed speed vv. The dog reads the gopher's body language, instantly figures out which hole the gopher chose, and runs in a straight line toward that same hole at twice the gopher's speed, 2v2v. If the dog reaches the hole first, it eats the gopher; otherwise the gopher escapes. If both reach the hole at the same instant, the gopher is considered to escape.

You are helping the gopher: decide whether it can escape through some hole.

Input

The first line contains four floating-point numbers: the (x,y)(x, y) coordinates of the gopher followed by the (x,y)(x, y) coordinates of the dog. Each of the following lines contains two floating-point numbers: the (x,y)(x, y) coordinates of one gopher hole. All distances are in metres, given to the nearest millimetre. There are at most 10001000 gopher holes, and every coordinate is between −10000-10000 and 1000010000.

Output

Print a single line. Consider the gopher holes in the order they appear in the input. The gopher can escape through a hole if it reaches that hole no later than the dog, that is, if twice the gopher-to-hole distance is at most the dog-to-hole distance.

If at least one such hole exists, output the first one in input order in the form:

The gopher can escape through the hole at (x,y).

where x and y are that hole's coordinates printed to the nearest millimetre (three decimal places). If no hole lets the gopher escape, output:

The gopher cannot escape.

Examples3

  1. Example 1

    Input
    1.000 1.000 2.000 2.000
    1.500 1.500
    
    Expected output
    The gopher cannot escape.
    
  2. Example 2

    Input
    0.000 0.000 10.000 10.000
    1.000 0.000
    
    Expected output
    The gopher can escape through the hole at (1.000,0.000).
    
  3. Example 3

    Input
    0.000 0.000 10.000 0.000
    5.000 0.000
    1.000 0.000
    
    Expected output
    The gopher can escape through the hole at (1.000,0.000).