#P9571. Drawing Board Operations

    ID: 22718 Type: Default 1000ms 256MiB

Drawing Board Operations

Drawing Board Operations

You are given an empty drawing board. You need to process ( n ) operations. There are three types of operations:

  1. Operation 1: (1; k; b) – Draw a line with the equation ( y = kx + b ) on the board.
  2. Operation 2: (2; k; b) – Query how many lines on the board have exactly one common point with the line ( y = kx + b ). Note that if a drawn line is coincident with the query line (i.e. they have the same ( k ) and ( b )), they are considered to have infinitely many common points and should not be counted. Also, lines that are parallel (same ( k ) but different ( b )) do not intersect and should not be counted.
  3. Operation 3: (3; k; b) – Erase (remove) all lines on the board that have at least one common point with the line ( y = kx + b ). In other words, remove all lines that intersect with the given line. Note that if two lines are parallel (with the same ( k ) but different ( b )) they will not intersect and should not be removed; however, coincident lines (with the same ( k ) and ( b )) should be removed.

    If two lines have different slopes, they intersect at exactly one point. Process the operations sequentially and output the answer for each query operation (Operation 2).

inputFormat

The first line contains an integer ( n ) – the number of operations. Each of the next ( n ) lines contains three integers. The first integer denotes the type of operation ( op ) (which can be 1, 2, or 3) and the next two integers are ( k ) and ( b ), which describe the line (y = kx + b).

outputFormat

For each operation of type 2, output the corresponding answer on a new line.

sample

6
1 1 1
1 1 2
1 2 3
2 1 1
3 1 1
2 2 3
1

1

</p>