eolymp
bolt
Try our new interface for solving problems
Problems

Hungry Queen

Hungry Queen

Consider an infinite chessboard with cells identified by pairs of integer numbers: (\textbf{x}, \textbf{y}). The black queen is initially located at the cell (\textbf{0}, \textbf{0}). The queen can move horizontally, vertically or diagonally, but cannot move downwards. That is, after each turn the \textbf{y}-coordinate of the cell where the queen is after the turn must be greater or equal to the \textbf{y}-coordinate of the cell where it was before the turn. There are \textbf{n} white pawns on the board, they are located at cells (\textbf{x_i}, \textbf{y_i}), where \textbf{y_i} > \textbf{0}. The queen wants to take as many pawns as possible. White pawns do not move, and the queen can make as many consecutive turns as needed. However, each turn the queen must take a pawn. Find out what is the maximal number of pawns the queen can take, and which pawns it must take to achieve this number. \InputFile The first line of the input file contains \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{50000}). The following \textbf{n} lines contain two integer numbers each - the coordinates (\textbf{x_i}, \textbf{y_i}) of the pawns (|\textbf{x_i}| ≤ \textbf{10^9}, \textbf{0} < \textbf{y_i} ≤ \textbf{10^9}). No two pawns occupy the same position. \OutputFile The first line of the output file must contain one integer number \textbf{k} - the number of pawns the queens can take. The second line must contain \textbf{k} integer numbers - the numbers of the pawns the queen can take in order she must do it. The pawns are numbered starting from 1 in order they are given in the input file.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4
1 1
4 3
-1 3
4 2
Output example #1
3
1 3 2