Huge stones

3.5

20 votes
Medium, Geometry, approximate, Mathematics, Circle, Geometry
Problem

There are N huge stones in the field, located in points P1,P2,,PN (not necessarily different). Their weights are positive integer numbers W1,W2,,WN.

You want to make a view on this field picturesque. To do this you should move these stones to the new points P1,P2,,PN, such that these points are lying at some circle. Let's define the difficulty to make this as a real number equal toNk=1dist(Pi,Pi)Wi.

You want to find some circle with center in point (X0,Y0) and radius R , such that the difficulty to make all stones lying on this circle as minimal as possible. Points P1,P2,,PN will be chosen optimally for your circle, you should find only the circle.

Input format

  • On the first line, you are given one integer number N (number of stones).
  • On the next N lines you are given 3 integer numbers  Xi,Yi,Wi,coordinates of point Pi and weight of i-th stone.

Output format

  • Print 3 real numbers X0,Y0,R coordinates of the center of the optimal circle and its radius. This numbers should satisfy the conditions 106X0,Y0106  and 0R4106.  

Constraints

  • N=50000 in all test cases except sample test
  • Pi=(Xi,Yi),106Xi,Yi106,1Wi106

NoteThe input data contains only 50 percent of the original test data. The other data will be added after the contest and the submissions will be rejudged.

Verdict and scoring
If numbers X0,Y0,R don't satisfy the required conditions you will get a Wrong Answer verdict. For each of the valid output points P1,P2,,PN will be generated, such that difficulty as minimum as possible.

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

In the sample test, we can choose (X0,Y0)=(1,2) and R=1

In this case, most optimal points are: P1=(1,3)P2(0,2929,1,2929)P3=(2,2)P4(1.8944,1,5528). The minimal possible difficulty for this circle is 3,6503

Editor Image

?