Hide

# Flight Collision

Drone by Hyeri Kim, Pixabay
The Icelandic Corporation for Parcel Circulation is the leading carrier for transporting goods between Iceland and the rest of the world. Their newest innovation is a drone link connecting to mainland Europe that has a number of drones travelling back and forth along a single route.

The drones are equipped with a sophisticated system that allows them to fly evasive manoeuvres whenever two drones come close to each other. Unfortunately, a software glitch has caused this system to break down and now all drones are flying along the route with no way of avoiding collisions between them.

For the purposes of this problem, the drones are considered as points moving along an infinite straight line with constant velocity. Whenever two drones are at the same location, they will collide, causing them to fall off their flight path and plummet into the Atlantic Ocean. The flight schedule of the drones is guaranteed to be such that at no point will there be three or more drones colliding at the same location.

You know the current position of each drone as well as their velocities. Your task is to assess the damage caused by the system failure by finding out which drones will continue flying indefinitely without crashing.

## Input

The input consists of:

• One line with an integer $n$ ($1 \leq n \leq 10^5$), the number of drones. The drones are numbered from $1$ to $n$.

• $n$ lines, the $i$th of which contains two integers $x_ i$ and $v_ i$ ($-10^9\leq x_ i,v_ i \leq 10^9$), the current location and the velocity of the $i$th drone along the infinite straight line.

The drones are given by increasing $x$ coordinate and no two drones are currently in the same position, i.e. $x_ i < x_{i+1}$ for each $i$. You may assume that there will never be a collision involving three or more drones.

## Output

Output the number of drones that never crash, followed by the indices of these drones in numerically increasing order.

Sample Input 1 Sample Output 1
3
10 15
30 5
50 -1

1
3

Sample Input 2 Sample Output 2
6
0 3
2 2
3 1
4 3
5 2
6 3

2
1 6

CPU Time limit 5 seconds
Memory limit 1024 MB
Difficulty 6.9hard
Statistics Show
Downloads
Author
License

Please log in to submit a solution to this problem