Problem A. Archery Tournament
Time limit: 3 seconds
You were invited to the annual archery tournament. You are going to compete against the best archers from all of the Northern Eurasia. This year, a new type of competition is introduced, where a shooting range is dynamic and new targets might appear at any second. As the shooting range is far enough from you, it can be represented as a 2D plane, where y = 0 is the ground level. There are some targets in a shape of a circle, and all the targets are standing on the ground. That means, if a target’s center is (x, y) (y > 0), then its radius is equal to y, so that it touches the line y = 0. No two targets simultaneously present at the range at any given time intersect (but they may touch). Initially, the shooting range is empty. Your participation in this competition can be described as n events: either a new target appears at the range, or you shoot an arrow at some point at the range. To hit a target, you must shoot strictly inside the circle (hitting the border does not count). If you shoot and hit some target, then the target is removed from the range and you are awarded one point.
Input
The first line of the input contains integer n (1 ≤ n ≤ 2·105 ). Next n lines describe the events happening at the tournament. The i-th line contains three integers ti , xi , and yi (ti = 1, 2; −109 ≤ xi , yi ≤ 109 ; yi > 0). • If ti = 1, then a new target with center (xi , yi) and radius yi appears at the range. • If ti = 2, then you perform a shot, which hits the range at (xi , yi).
Output
For each of your shots, output a separate line with the single integer. If the shot did not hit any target, print “-1”. If the shot hit a target, print the number of event when that target was added to the range. Events are numbered starting from 1.
Examples
input
8
1 0 12
2 - 11 22
1 24 10
1 12 3
2 12 12
2 16 14
1 28 15
2 3 6
output
-1
-1
3
1
Note
Illustration shows the state of the range after first six events. The rightmost target was hit by the last shot and is going to be removed.
一、原题地址
点我传送
二、大致题意
给出n个操作,
操作1表示建立一个位于(x,y)且半径为y的靶子。
操作2表示往(x,y)处开一枪。
要求在每次开枪的时候,给出枪是否命中了靶子,若命中了则输出靶子的编号,并且删除这个靶子,若没有命中则输出-1
三、思路
将靶子的横轴坐标离散在线段树上。
在线段树上的每个节点开一个set,用以记录在这个区间内存在的靶子编号。
对于每次开枪的操作,查询并且删除。
四、代码
#include
#include
#include
#include