This page is still under construction.

Parts of this page are still being built. What you see may change.

Orbit

Time limit2sMemory limit256 MB

Summary
Place two opposite sensors on the radius-R circle so their brightest-star readings match, and print the pair with the smallest angle.
Level

Hard9 of 10

Topics
Geometry, Math, Binary search
Solved
No attempts yet

Problem

In this universe every celestial body is a point of a plane, and the Earth is the point (0,0)(0, 0). The universe holds NN stars. Star ii sits at (xi,yi)(x_i, y_i) and its luminosity is LiL_i. No star ever moves, and the universe holds nothing besides the bodies named here.

Two deep space sensors will be placed on the orbit of radius RR around the Earth, so each sensor sits at distance RR from (0,0)(0, 0). A star of luminosity LL at distance rr from a point produces the brightness F=L4πr2F = \frac{L}{4 \pi r^2} at that point, and the brightness a sensor observes is the largest of the brightnesses that the NN stars produce at its position. The distance between (xi,yi)(x_i, y_i) and (xj,yj)(x_j, y_j) is r=(xi−xj)2+(yi−yj)2r = \sqrt{(x_i - x_j)^2 + (y_i - y_j)^2}. The sensors, the Earth and the stars are points of negligible size.

The two sensors must observe the same brightness, and among the placements that meet that condition the distance between the sensors must be as large as possible. Two points of the orbit are never farther apart than 2R2R, and a pair at distance exactly 2R2R with equal observed brightness always exists, so the two sensors face each other across the Earth.

Write the first sensor at (Rcos⁡θ,Rsin⁡θ)(R \cos \theta, R \sin \theta) with 0≤θ<π0 \le \theta < \pi. The second sensor is then (−Rcos⁡θ,−Rsin⁡θ)(-R \cos \theta, -R \sin \theta). Several values of θ\theta can satisfy the condition, so report the smallest one.

Input

The first line has two integers NN and RR, the number of stars and the radius of the orbit, separated by one space. Each of the next NN lines has three integers xix_i, yiy_i, LiL_i: the coordinates and the luminosity of star ii. RR, xix_i and yiy_i use the same unit.

Output

Print four real numbers X1X_1, Y1Y_1, X2X_2, Y2Y_2 on one line, separated by single spaces: the position of the first sensor and the position of the second sensor. Round every number to exactly 6 digits after the decimal point. Here θ\theta is the smallest angle in [0,π)[0, \pi) at which the two sensors observe the same brightness, (X1,Y1)=(Rcos⁡θ,Rsin⁡θ)(X_1, Y_1) = (R \cos \theta, R \sin \theta) and (X2,Y2)=(−X1,−Y1)(X_2, Y_2) = (-X_1, -Y_1). Print a rounded value of zero as 0.000000, never as -0.000000.

Limits

  • 1≤N≤1000001 \le N \le 100000
  • 1≤R≤100001 \le R \le 10000
  • ∣xi∣≤10000|x_i| \le 10000
  • ∣yi∣≤10000|y_i| \le 10000
  • 1≤Li≤1091 \le L_i \le 10^9
  • Every number in the input is an integer.

Hint

Let b(θ)b(\theta) be the brightness observed at (Rcos⁡θ,Rsin⁡θ)(R \cos \theta, R \sin \theta) and let di(θ)d_i(\theta) be the distance from that point to star ii. Then b(θ)=14π⋅1min⁡idi(θ)2/Lib(\theta) = \frac{1}{4 \pi} \cdot \frac{1}{\min_i d_i(\theta)^2 / L_i}, so comparing b(θ)b(\theta) with b(θ+π)b(\theta + \pi) is the same as comparing min⁡idi(θ)2Li\min_i \frac{d_i(\theta)^2}{L_i} with min⁡idi(θ+π)2Li\min_i \frac{d_i(\theta + \pi)^2}{L_i}. The difference of the two minima is continuous in θ\theta and takes opposite values at θ\theta and at θ+π\theta + \pi, so it is zero for at least one θ\theta in [0,π)[0, \pi).

Examples4

  1. Example 1

    Input
    1 2
    10 0 3
    
    Expected output
    0.000000 2.000000 0.000000 -2.000000
    
  2. Example 2

    Input
    1 3
    0 7 5
    
    Expected output
    3.000000 0.000000 -3.000000 0.000000
    
  3. Example 3

    Input
    1 15
    -6 -8 100
    
    Expected output
    -12.000000 9.000000 12.000000 -9.000000
    
  4. Example 4

    Input
    4 5
    7 -9 36
    0 8 12
    -8 -3 12
    10 -3 30
    
    Expected output
    4.969322 0.553027 -4.969322 -0.553027