Sheep and Coyotes
Time limit1sMemory limit128 MB
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.
Problem
A square 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 , the northwest corner at , the northeast corner at , and the southeast corner at . Thus the coyote enters at some point on the south edge with .
Input
The first line contains the number of sheep (). For each sheep, two lines follow: the first gives its coordinate and the second its coordinate. Every coordinate is between and 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 and are the sheep's coordinates to two decimal places (printed exactly as given in the input). Print the sheep sorted by increasing ; if two sheep share the same , sort them by increasing . If several sheep share identical coordinates, print one line for each.