Archery Tournament
Time limit3sMemory limit512 MB
Maintain a dynamic set of non-overlapping circles tangent to the ground, support insertions and point queries that remove the hit circle, and report which circle each arrow hits.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Sorting, Implementation
- Solved
- No attempts yet
Problem
You were invited to the annual archery tournament, where you compete against the best archers from all of Northern Eurasia. This year the organizers introduced a new format: the shooting range keeps changing, and a new target appears at any moment.
The range is far enough away that you can treat it as a 2D plane whose ground is the line . Every target is a circle standing on the ground. If a target has center with , then its radius equals , so the target touches the line . Two targets that are present at the range at the same time never overlap in their interiors. Their boundaries may touch.
The range is empty at the start. Your part in the tournament is described by events. An event either adds a new target to the range or shoots an arrow at one point of the range. To hit a target you must shoot strictly inside its circle. Hitting the border does not count. When your arrow hits a target, that target is removed from the range and you are awarded one point.
Input
The first line contains an integer (). The next lines describe the events of the tournament in chronological order. The -th of these lines contains three integers , , ( or , , ).
- If , a new target with center and radius appears at the range.
- If , you shoot an arrow, and the arrow hits the range at the point .
Output
For each of your shots, print one line with a single integer. If the shot hit no target, print -1. If the shot hit a target, print the number of the event that added that target to the range. Events are numbered starting from 1.
Hint

The picture shows the range after the first six events of the example. The rightmost target is hit by the last shot and is about to be removed.