Proper Garden
Time limit3sMemory limit256 MB
Given n tree points, find two trees at opposite corners of an axis-parallel rectangle with no other tree inside or on its border, or report that none exists.
- Level
Medium7 of 10
- Topics
- Sorting, Geometry, Binary search
- Solved
- No attempts yet
Statement
Vasya has dreamed of his own garden for a long time. Recently he acquired a plot of land and set up a Cartesian coordinate system on it. He decided to plant trees. His friend Petya, an enthusiastic gardener, told Vasya the main rule of planting: in any rectangle of nonzero area with sides parallel to the coordinate axes, if two opposite corners hold trees, then there must be at least one other tree inside the rectangle or on its border.
Vasya has a planting plan but is not sure whether it follows the rule. Help him determine this.
Input
The first line contains an integer (). Each of the next lines contains two integers and (), the coordinates of tree . No two trees are at the same point.
Output
If the plan satisfies the rule, print the single word YES. Otherwise, print NO on the first line, and on the second line print two different numbers and , the indices of the trees at opposite corners of a rectangle that breaks the rule. If there are several such pairs, print any of them.