SP22331 ZQUERY2 - Intersection Query
Description
Considering a set of segments. At the beginning, the set is totally empty.
There are **N** operations: insert or erase a _vertical_ (or _horizontal_) segment and then you have to compute how many intersections are there.
_There is no two same type of segments that share a common point in the set_.
Input Format
The first line contains **N** (**1** N 10 $ ^{5} $ ) - the number of operations.
The following **N** lines describe the operations:
- **1 X $ _{1} $ Y $ _{1} $ X $ _{2} $ Y $ _{2} $** : insert a segment whose two endpoints are **(X $ _{1} $ , Y $ _{1} $ )** and **(X $ _{2} $ , Y $ _{2} $ )** to the set. (|**X $ _{1} $** |, |**Y $ _{1} $** |, |**X $ _{2} $** |, |**Y $ _{2} $** | 10 $ ^{9} $ )
- **2 K**: erase the **K-th** oldest segment from the set. (**1** K
Output Format
For each query, print the number of intersections of the line segments in the set after processing the operation in one line.