WC '17 Contest 2 S3 - Battle of the Pelennor FIelds

View as PDF

Submit solution

Points: 12 (partial)
Time limit: 2.75s
Memory limit: 128M

Author:
Problem type
Woburn Challenge 2017-18 Round 2 - Senior Division

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 \le N \le 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 E_{i} (1 \le E_{i} \le 2):

  • If E_{i} = 1, then an orc arrives on the battlefield at position O_{i} (0 \le O_{i} \le 10^{9}).
  • Otherwise, if E_{i} = 2, then a Gondorian archer arrives on the battlefield at position A_{i} (0 \le A_{i} \le 10^{9}), and having a bow range of R_{i} (1 \le R_{i} \le 10^{9}). Such an archer is able to shoot any orcs which are at most R_{i} units of distance away from A_{i}.

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 \le 1000 and R_{i} = 1 for each applicable i.
In test cases worth another 4/27 of the points, R_{i} = 1 for each applicable i.
In test cases worth another 8/27 of the points, R_{i} = 10^{6} for each applicable i.

Input Specification

The first line of input consists of a single integer, N.
N lines follow, the i^{th} of which consists of a single integer, E_{i}, followed by either 1 more integer O_{i} (if E_{i} = 1) or 2 more integers A_{i} and R_{i} (if E_{i} = 2), for i = 1 \ldots
N.

Output Specification

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 2^{nd} event, there are still no archers on the field, meaning that both orcs are non-vulnerable. After the 3^{rd} 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 7^{th} event, the orcs at positions 22 and 23 are still non-vulnerable, while the remaining 3 orcs are vulnerable.


Comments

There are no comments at the moment.