Cosmic Pursuit
Time limit1sMemory limit512 MB
You order integer-time shots so each pursuer is destroyed before it reaches your ship.
Problem
Bajtoks, a galactic troublemaker, is in hot water again. Right now he is fleeing in his spaceship from a squad of Bitoks.
Luckily he is not alone. On board with him are Bajtinoks, the laser cannon gunner, and you, the programmer running the ship's computer. The Bitoks are a rather primitive species with no long range weapons, so they simply try to catch up to Bajtoks's ship. Bajtinoks is a crack shot and never misses, but he does not know in which order to fire at the enemies. That is exactly your job.
Write a program that computes the order in which Bajtinoks should fire so that the crew shoots down every pursuer and escapes.
Input
The first line contains one integer (), the number of enemy ships. The second line contains two integers and (, ), separated by a single space, the initial position and speed of Bajtoks's ship.
Each of the next lines describes one enemy ship with two integers and (, ), separated by a single space, the initial position and speed of the -th enemy ship. All positions are in bytemeters and all speeds in bytemeters per bytesecond. Every ship moves along the same straight line in the same direction.
Between any two shots at least one bytesecond must pass so that Bajtinoks can reload the cannon. During that second every ship moves by its own speed . If during this movement any enemy ship reaches the same position as Bajtoks, the hero loses. The only exception: if exactly one enemy ship reaches that position and it does so precisely at the instant the reload finishes (an integer time), that enemy can still be shot down.
At the start of the chase Bajtinoks is already ready to fire, so no reload is needed before the first shot. Shots therefore happen at times
Initially Bajtoks's ship is ahead of all the others (that is, for every ). Ships pass one another without any trouble. Bajtinoks can hit any enemy, the laser's travel time is negligible, and a single hit destroys any ship.
Output
If Bajtoks's crew can shoot down every pursuer, print the firing order on a single line: a permutation of the integers through , where the -th number is the index of the enemy destroyed by the -th shot. If several firing orders let Bajtoks escape, print the lexicographically smallest one.
If escape is impossible and the crew is doomed, print GAME OVER on a single line.
Notes
In the example, enemy reaches Bajtoks at time , so it must be shot no later than time , while enemies and arrive much later. Among all winning orders the lexicographically smallest is 1 2 3. Firing in this order, enemy is destroyed exactly at time , the instant the reload finishes (it is the only enemy at Bajtoks's position at that moment), so the crew survives that close call.