The Agglomerator

Simulate moving circular droplets that merge on contact with area-weighted position and velocity, and report the final count and last merge time.

Medium6SimulationMathGeometryNo attempts yetTime limit3sMemory limit256 MB

Problem

You simulate the motion of droplets in a plane. Each droplet is a circle of some size that moves at a constant velocity. The moment two circles touch, they agglomerate into a single circular droplet whose area is the sum of the two areas. The new droplet's center is the area weighted average of the two centers at the moment of contact, and its velocity is the area weighted average of the two velocities.

The figure illustrates the process. In the top panel, a droplet of radius 4 centered at (14,0)(-14, 0) moves with velocity (1,0)(1, 0) toward a stationary droplet of radius 3 centered at the origin. The two circles touch at time t=7.0t = 7.0, which is the middle panel.

At that moment the droplet of radius 4 is centered at (7,0)(-7, 0). The two areas are 16π16\pi and 9π9\pi, so the new droplet has area 25π25\pi and radius 5. The xx coordinate of the agglomerated droplet is 1625(7.0)+9250.0=4.48\frac{16}{25} \cdot (-7.0) + \frac{9}{25} \cdot 0.0 = -4.48 and the yy coordinate is 16250.0+9250.0=0.0\frac{16}{25} \cdot 0.0 + \frac{9}{25} \cdot 0.0 = 0.0. The same calculation gives the velocity (0.64,0)(0.64, 0).

Given the initial configuration, simulate the motion until no further agglomeration can occur. Report how many droplets remain and the time of the last agglomeration.

Every test satisfies the following:

  • No two of the original droplets touch.
  • When an agglomeration forms a new droplet, that droplet touches no other droplet at the moment it is formed. It is at least 0.0010.001 away from touching any of them.
  • No two droplets ever pass each other with a single point of intersection. Growing or shrinking the radius of any droplet by 0.0010.001 does not change whether it collides with another droplet.
  • No two pairs agglomerate at exactly the same time. Consecutive agglomerations are at least 0.0010.001 apart in time.
  • No agglomeration happens after time t=109t = 10^9.
  • The exact value of the answer tt is at least 10710^{-7} away from the midpoint of two consecutive multiples of 10610^{-6}, so double precision arithmetic rounds it to six decimal places unambiguously.

Input

The first line contains the original number of droplets NN (2N1002 \le N \le 100).

Each of the next NN lines contains five integers xx, yy, vxv_x, vyv_y, rr separated by spaces: the xx coordinate of the center, the yy coordinate of the center, the xx component of the velocity, the yy component of the velocity, and the radius. These satisfy 10000x,y,vx,vy10000-10000 \le x, y, v_x, v_y \le 10000 and 1r1001 \le r \le 100.

Output

Print a single line with two values kk and tt separated by one space. kk is the number of droplets in the final configuration, and tt is the time at which the final agglomeration occurred.

Round tt to six decimal places and print exactly six digits after the decimal point. If no agglomeration occurs, kk equals the original number of droplets and tt is 0.000000.