Woburn Challenge 2017-18 Round 2 - Senior Division

Problem 3: Battle of the Pelennor Fields

An enormous, decisive battle is about to take place on the Pelennor Fields before the city of Minas Tirith! A noble army of Gondorian men will engage in battle against Sauron's evil army of orcs in an attempt to save their home and all of Middle Earth. Gandalf has given you your own vital task – not to actually participate in combat, but to report to him the state of the battle as it unfolds.

The battlefield can be represented as an infinite number line, and is initially empty. N (1 ≤ N ≤ 300,000) events will then occur over the course of the battle, one after another. The i-th event's type is indicated by the value Ei (1 ≤ Ei ≤ 2):

  • If Ei = 1, then an orc arrives on the battlefield at position Oi (0 ≤ Oi ≤ 109).
  • Otherwise, if Ei = 2, then a Gondorian archer arrives on the battlefield at position Ai (0 ≤ Ai ≤ 109), and having a bow range of Ri (1 ≤ Ri ≤ 109). Such an archer is able to shoot any orcs which are at most Ri units of distance away from Ai.

All N combatants' positions are distinct.

An orc is "vulnerable" if there's at least one archer on the battlefield who is able to shoot that orc. After each of the N events, you'd like to report to Gandalf the number of orcs currently on the battlefield which are not vulnerable.

Subtasks

In test cases worth 4/27 of the points, N ≤ 1000 and Ri = 1 for each applicable i.
In test cases worth another 4/27 of the points, Ri = 1 for each applicable i.
In test cases worth another 8/27 of the points, Ri = 106 for each applicable i.

Input Format

The first line of input consists of a single integer, N.
N lines follow, the i-th of which consists of a single integer, Ei, followed by either 1 more integer Oi (if Ei = 1) or 2 more integers Ai and Ri (if Ei = 2), for i = 1..N.

Output Format

Output N lines, the i-th of which should consist of a single integer, the number of non-vulnerable orcs on the battlefield after the first i events.

Sample Input

7
1 15
1 22
2 18 3
1 19
2 5 12
1 23
1 0

Sample Output

1
2
1
1
1
2
2

Sample Explanation

After the 2nd event, there are still no archers on the field, meaning that both orcs are non-vulnerable. After the 3rd event, the newly-arrived archer is just barely able to shoot the first orc, while the second orc is too far away and so is still non-vulnerable. After the 7th event, the orcs at positions 22 and 23 are still non-vulnerable, while the remaining 3 orcs are vulnerable.

All Submissions
Best Solutions


Point Value: 13 (partial)
Time Limit: 6.00s
Memory Limit: 128M
Added: Feb 23, 2018
Author: SourSpinach

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

It's quiet in here...