#P6952. Dynamic Archery Tournament
Dynamic Archery Tournament
Dynamic Archery Tournament
You are invited to the annual archery tournament. This year, the shooting range is dynamic and new targets may appear at any second. The range is modeled as a 2D plane where the ground is the line \(y=0\). A target appears as a circle standing on the ground: if a target's center is \((x, y)\) with \(y>0\), then its radius is \(y\) (so that it touches the ground at \(y=0\)). It is guaranteed that no two targets present at the range at the same time intersect (although they may touch).
You will be given \(n\) events. Each event is one of the following two types:
- Add Event:
1 x y
— A new target appears with center \((x, y)\) and radius \(y\). - Shooting Event:
2 x y
— You shoot an arrow at the point \((x, y)\).
An arrow is considered to hit a target if it lands strictly inside the circle (landing exactly on the boundary does not count). When an arrow hits a target, that target is removed from the range and you are awarded one point. Your task is to simulate these events in the order given and output the total score (the total number of targets hit).
inputFormat
The first line contains an integer (n) ((1 \le n)), the number of events. Each of the following (n) lines represents an event and is in one of the two formats:
1 x y
— A target appears at the range with center \((x, y)\) (\(y>0\); its radius is \(y\)).2 x y
— You shoot an arrow at the point \((x, y)\).
It is guaranteed that at any moment, the targets present do not intersect (though they may touch).
outputFormat
Output a single integer: the total score (the number of targets hit) after processing all events.
sample
4
1 3 3
2 3 2
2 3 3
1 5 2
1