CIRCLES - Circles

Little Gary plays the following video game. Circles pop up on the screen and disappear from it. When the screen flashes, Gary can draw a straight line on the screen and win as many points as there are circles intersected by the line. As a born-to-be-winner, Gary wants to maximize his score. Please, help him, and write a program that will determine the maximum number of points he can win each time the screen flashes.

Input

The first line of the input contains M (1M1000), the number of events during the game. The next M lines contain descriptions of the events, one per line. They can be in one of the following three formats:

1 x y r
, representing a circle of radius r popping up with the position of its center at (x, y) in the plane

2 i
, representing a circle i disappearing, where circle i is the ith circle that popped up since the beginning of the game; and

3
, representing the screen flashing.

x, y, and r are real numbers with at most two decimals, -106 < x, y, r < 106, r > 0.

Notes:

  • A line intersects a circle if it has at least two common points with it.
  • At any time, no two Circles on the screen have a common point.
  • At any time, there is no line that "touches" more than two circles (a line touches a circle if they have exactly one common point).
  • At any time, there are no more than 100 circles on the screen.
  • Each i determines a circle that is on the screen at the moment of removal.
  • No circle is removed twice.

Output

Each time the screen flashes, write an integer to a separate line, which is the maximum number of circles Gary can intersect.

Example

Input:
9
1 3.00 0.00 1.00
1 -2.00 0.00 1.00
3
1 2.00 3.00 1.50
3
1 2.00 -4.00 1.00
3
2 3
3

Output:
2
2
3
2

Added by:Minilek
Date:2007-10-25
Time limit:7.929s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET

hide comments
2022-07-27 20:28:14 David
First Java Solution!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.