Drone Elimination
InterviewTime limit2sMemory limit1024 MB
Given n drone positions, find a shooting order so that no drone reaches the origin when drones move one step in any of 8 directions after each shot, or report -1.
Statement
Ralph escaped from his game, so specially trained drones were sent to find him. Ralph is not easy to catch, though, and he has set up a defensive position with a turret in his hands.
After studying the situation, Ralph worked out that on a plane with him at the origin , drone is at the point . While Ralph was scouting, the drones spotted him, so he has to act now. Each second, Ralph can shoot any one drone with his turret. After each shot, every surviving drone can move to any of the 8 points adjacent to it horizontally, vertically, or diagonally. Several drones may end up at the same coordinates.
The drones want to reach Ralph at , and Ralph wants to destroy all of them before they reach him. Ralph guarantees that he never misses and that each shot destroys exactly one drone. Tell him the order in which to shoot the drones so that none of them reaches . If that is impossible, say so, and Ralph should run.
Input
The first line contains the number of drones (). Each of the next lines contains two integers and , the coordinates of drone (). It is guaranteed that no drone is at .
Output
Print integers from 1 to on a single line, separated by spaces. These are the numbers of the drones in the order Ralph should shoot them. If some drone reaches no matter what, print "-1" on a single line. If several solutions exist, you may print any of them.