P9571 "NnOI R2-T3" Horizon Blue

Description

Little C likes drawing on a drawing board. He performs $n$ operations. Each operation can be one of the following three types: - ```1 k b``` means Little C draws a line with equation $y = kx + b$. - ```2 k b``` means Little C asks you: the line $y = kx + b$ has **exactly** one common point with how many drawn lines? - ```3 k b``` means Little C erases all lines that have **at least** one common point with the line $y = kx + b$. **Note: Two overlapping (coincident) lines have infinitely many intersection points.** **Note: During queries, coincident lines should be counted separately.**

Input Format

The first line contains an integer $n$. The next $n$ lines each contain three integers $1/2/3, k, b$, representing one operation.

Output Format

For each ```2 k b``` operation, output the number of lines that satisfy the requirement.

Explanation/Hint

**[Sample 1 Explanation]** In the 1st operation, draw the line $y = x$. In the 2nd operation, draw the line $y = -x$. In the 3rd operation, you can see that the line $y = 2x + 1$ intersects the previous two lines. In the 4th operation, erase all lines that intersect $y = x + 3$; the line $y = -x$ is erased. In the 5th operation, $y = 2x + 1$ obviously intersects $y = x$. In the 6th operation, $y = x + 1$ has the same slope as $y = x$, so they are parallel and do not intersect. **[Constraints]** For $100\%$ of the testdata, $1 \le n \le 10^5$, $1 \le |k| \le 10^5$, $0 \le |b| \le 10^5$. **Hint: This problem uses bundled tests.** $$ \def\r{\cr\hline} \def\None{\text{None}} \def\arraystretch{1.5} \begin{array}{c|c|c} \textbf{Subtask} & \textbf{Sp. Constraints} & \textbf{Score}\r \textsf1& n \le 5000 & 27 \r \textsf2& \vert k\vert,\vert b\vert \le 50 & 21 \r \textsf3& No type 3 operations & 13 \r \textsf4& The $i$-th operation satisfies $k = i$ & 14 \r \textsf5& No special constraints & 25 \r \end{array} $$ The hack test points added after the contest will be placed into subtask 6. ### Source | Item | People | |:-:|:-:| | idea | 船酱魔王 (Chuánjiàng Mówáng) | | data | 船酱魔王 (Chuánjiàng Mówáng) | | check | EstasTonne | | solution | 船酱魔王 (Chuánjiàng Mówáng) | Translated by ChatGPT 5