Under construction

Still being built. Things may change

Growing Some Oobleck

Time limit1sMemory limit1024 MB

Summary
Given circles that grow at fixed rates, find the center and radius of the single circle formed after all touching circles merge in chain reactions.
Level

Medium6 of 10

Topics
Simulation, Geometry, Implementation
Solved
No attempts yet

Statement

Oobleck is a fascinating magical substance. Leave it in sunlight and it grows in an ever-expanding circle. If two circles ever touch, both circles merge into one combined circle. The area of the combined circle equals the total area of both circles, and its center is at the midpoint of the two original centers. The expansion rate of the new circle is the larger of the rates of the two colliding circles. See Figures F.1 and F.2 for an example.

Figure F.1: Circle A has center (10,10)(10,10), radius 66 and area 36π36\pi. Circle B has center (24,10)(24,10), radius 88 and area 64π64\pi.

Figure F.2: After they merge, they are replaced by circle C with center (17,10)(17,10), radius 1010 and area 100π100\pi.

After a new circle is created, it may intersect other existing circles, causing a chain reaction of merges. This combination of an intersection followed by one or more merges is called an ooblection. An ooblection occurs instantaneously at the moment of the first intersection, even though it may contain a cascade of merges. When three or more circles are involved in a merge, the resulting circle has its center at the average of the centers of all circles involved, and its area is the sum of their areas. The expansion rate of the final circle after an ooblection is the maximum rate of any circle involved.

Figure F.3: A five-circle ooblection.

Figure F.3 shows a five-circle ooblection, described in the second sample. At time t=1t=1 the circles have expanded to the state in Figure F.3a. At that time circles A and B merge into circle F (Figure F.3b). Circle F intersects circles C and D and merges with them into circle G (Figure F.3c). Finally, circle G intersects circle E and produces the final circle H (Figure F.3d). All of this happens at time t=1t=1. The expansion rate of circle H is the maximum expansion rate of circles A through E. With the values in Sample Input 2, this maximum is 2.

As any set of circles grows, they will eventually ooblect into a single circle. Your task is to find the position and area of that circle at the moment it is created.

Input

The first line contains a positive integer nn (n≤100n \leq 100), the number of circles. The next nn lines each contain four numbers xx, yy, rr and ss. xx and yy (−109≤x,y≤109-10^9 \le x,y \le 10^9) give the center of the circle. rr (1≤r≤1061 \leq r \leq 10^6) is the initial radius. ss (1≤s≤1061 \leq s \leq 10^6) is the expansion rate. No two circles in the input are touching. At most one ooblection begins at any given moment, and each ooblection starts with the touching of exactly two circles.

Output

Output two lines. The first line contains two numbers xx and yy, the center of the final circle at the moment it is created. The second line contains the radius of that circle. Answers are accepted with a relative or absolute error of 10−610^{-6}.

Examples2

  1. Example 1

    Input
    2
    1 1 1 1
    5 1 1 1
    
    Expected output
    3.00000000 1.00000000
    2.82842712
    
  2. Example 2

    Input
    5
    3 4 5 1
    17 4 7 1
    10 -13 6 2
    10 21 7 1
    -7 4 1 1
    
    Expected output
    1.50000000 4.00000000
    15.23154621