Farm
Time limit1sMemory limit1024 MB
Find a longest route of trees Mr. P can visit by driving straight left, right, up, or diagonally up, and the fewest road rollers that cover the non-horizontal ruts.
Statement
The farm can be treated as a two-dimensional Euclidean plane. There are trees, numbered . Each tree is a point on the plane, and tree has coordinates . All tree coordinates are pairwise distinct.
Mr. P starts at the origin and drives. In each round, he chooses one of five directions: left, right, up, 45 degrees upper left, or 45 degrees upper right. A direction can be chosen only if driving that way reaches a tree he has never visited. He drives straight in the chosen direction and stops at the nearest unvisited tree in that direction. If no direction is available, he stops. Mr. P follows an optimal route, meaning one that visits the most trees. If several optimal routes exist, he may choose any of them.
Mr. S found that Mr. P's car leaves a rut on the farm. A rut is a line segment between two trees, or between the origin and a tree. Mr. S considers ruts in directions other than left and right (up, 45 degrees upper left, and 45 degrees upper right) unsightly. He will rent road rollers to reinforce the areas that might have such ruts. Formally, these areas are the segments contained in at least one optimal route.
A road roller works as follows:
- It starts at the origin or at any tree.
- It may move up, 45 degrees upper left, or 45 degrees upper right. It may stop or change direction only at a tree.
- It may pass only through areas that might have non-horizontal ruts. An area may be passed by several road rollers.
Mr. P and Mr. S ask two questions: (1) find an optimal route for Mr. P, and (2) find the minimum number of road rollers needed.
Input
The first line contains an integer , the number of trees. Each of the next lines contains two integers and , separated by a single space, the coordinates of the -th tree.
Output
The output has three lines. The first line is , the maximum number of trees Mr. P may visit. The second line contains the trees Mr. P visits, separated by single spaces. The third line is the minimum number of road rollers required.