This page is still under construction.

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

Sheep and Coyotes

Time limit1sMemory limit128 MB

Summary
Given sheep points in a square, find which sheep is nearest to some entry point on the south edge, possibly selected when there is a tie.
Level

Medium6 of 10

Topics
Geometry, Sorting
Solved
No attempts yet

Problem

A square 1000×10001000 \times 1000 field contains several sheep. A coyote enters the field at some point on the south boundary and eats the sheep closest to its entry point; if several sheep are equally close, it picks one of them arbitrarily. Having eaten, the sated coyote leaves the field.

Determine which sheep may possibly be eaten by the coyote.

Assume the southwest corner of the field is at (0.00,0.00)(0.00, 0.00), the northwest corner at (0.00,1000.00)(0.00, 1000.00), the northeast corner at (1000.00,1000.00)(1000.00, 1000.00), and the southeast corner at (1000.00,0.00)(1000.00, 0.00). Thus the coyote enters at some point on the south edge y=0y = 0 with 0≤x≤10000 \le x \le 1000.

Input

The first line contains the number of sheep nn (1≤n≤10001 \le n \le 1000). For each sheep, two lines follow: the first gives its xx coordinate and the second its yy coordinate. Every coordinate is between 0.000.00 and 1000.001000.00 and is given to two decimal places.

Output

For each sheep that might be eaten, print one line in the form The sheep at (x, y) might be eaten., where xx and yy are the sheep's coordinates to two decimal places (printed exactly as given in the input). Print the sheep sorted by increasing xx; if two sheep share the same xx, sort them by increasing yy. If several sheep share identical coordinates, print one line for each.

Examples3

  1. Example 1

    Input
    6
    100.00
    100.00
    200.00
    150.00
    140.00
    200.00
    100.00
    300.00
    300.00
    300.00
    300.00
    100.00
    
    Expected output
    The sheep at (100.00, 100.00) might be eaten.
    The sheep at (300.00, 100.00) might be eaten.
    
  2. Example 2

    Input
    1
    500.00
    500.00
    
    Expected output
    The sheep at (500.00, 500.00) might be eaten.
    
  3. Example 3

    Input
    2
    500.00
    100.00
    500.00
    300.00
    
    Expected output
    The sheep at (500.00, 100.00) might be eaten.