Problem J
Antimatter Rain
You’ve heard of acid rain but have you heard of antimatter rain? Antimatter rain is so potent that when it comes into contact with another object, it immediately disintegrates both itself and the object. Kayla’s job as a SpaceFleet Researcher is gathering weather data on exotic planets. This time, their assignment is to monitor the antimatter rainfall.
Sensors are set up in the planet’s atmosphere and are about to be rained on with antimatter rain. Oh no! Kayla monitors a single 2D section. Each sensor is either a single horizontal strip or a single point. When one or more antimatter droplet fall on a single sensor, all of those droplets and the sensor disintegrate simultaneously. That is, they disappear. All other droplets will drop past where the sensor used to be.
Kayla sees all the antimatter rain drops the moment before they all start to fall. All droplets fall at exactly the same rate.
For each droplet, Kayla wants to know if and where it will disintegrate. Help them out with this demanding task!
![\includegraphics[width=0.4\textwidth ]{antimatter.pdf}](/problems/antimatterrain/file/statement/en/img-0001.png)
Illustration of the first sample. The vertical lines connect the drops to the sensor they hit. The drop with no associated vertical line will not hit any sensor.
Input
The first line of input contains two integers
The next
The next
It is guaranteed that no two drops will start in the same location, no drop will start on any sensor, and no two sensors touch (not even at a single point).
Output
For each droplet, in order, display a single number
indicating the
Sample Input 1 | Sample Output 1 |
---|---|
5 3 1 8 2 3 2 8 5 8 5 9 3 6 6 1 7 4 1 3 1 |
4 1 4 6 0 |
Sample Input 2 | Sample Output 2 |
---|---|
6 3 1 2 4 8 5 10 6 10 7 10 8 10 1 1 1 3 4 3 5 7 9 |
1 3 9 9 9 0 |