#P9571. 「NnOI R2-T3」Horizon Blue

「NnOI R2-T3」Horizon Blue

Problem Description

Little C likes drawing on a drawing board. He performs nn operations. Each operation can be one of the following three types:

  • 1 k b means Little C draws a line with equation y=kx+by = kx + b.
  • 2 k b means Little C asks you: the line y=kx+by = 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+by = 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 nn.

The next nn lines each contain three integers 1/2/3,k,b1/2/3, k, b, representing one operation.

Output Format

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

6
1 1 0
1 -1 0
2 2 1
3 1 3
2 2 1
2 1 1
2
1
0
10
1 1 0
1 1 0
2 1 1
2 1 0
2 2 5
3 1 0
2 2 5
1 2 3
1 3 4
2 3 5
0
0
2
0
1

Hint

[Sample 1 Explanation]

In the 1st operation, draw the line y=xy = x.

In the 2nd operation, draw the line y=xy = -x.

In the 3rd operation, you can see that the line y=2x+1y = 2x + 1 intersects the previous two lines.

In the 4th operation, erase all lines that intersect y=x+3y = x + 3; the line y=xy = -x is erased.

In the 5th operation, y=2x+1y = 2x + 1 obviously intersects y=xy = x.

In the 6th operation, y=x+1y = x + 1 has the same slope as y=xy = x, so they are parallel and do not intersect.

[Constraints]

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 1k1051 \le |k| \le 10^5, 0b1050 \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
check EstasTonne
solution 船酱魔王 (Chuánjiàng Mówáng)

Translated by ChatGPT 5