Filthy room P89133


Statement
 

pdf   zip

thehtml

Professor Filthy Frank has bought a new pet (whose name must remain undisclosed). He wants to prevent it from the horrible fate suffered by his previous hamster Stuart (which didn’t quite differ from that of his previous six pets). In particular, he wants to avoid using his sock to protect it from the cold. Can you find the warmest spot for Frank’s new pet?

Consider a bidimensional infinite world, where the temperature is given by the formula T(x,y) = px + qy + r. Frank’s room is an n-sided polygon determined by the intersection of n ‍half-planes, each one defined by the equation ai x + bi y + ci ≥ 0.

Input

Input consist of several cases, each one with n, p, q and r, followed by n triples ai bi ci defining the half-planes in any order. (For instance, below you can see the green room of the first sample case.) Assume 3 ≤ n ≤ 5000, that at least ai or bi is non-zero, and that the resulting room has indeed n sides.

Output

Print the highest temperature inside each room with three digits after the decimal point. The input cases do not have precision issues.

Observation

The expected solution has cost better than Θ(n2).





 ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ (10,5) unit=0.8cm, linewidth=0.8

linecolor=black

[fillcolor=green,fillstyle=solid](0,0)(2,0)(4,2)(3,4)(0,3)

->(0,0)(0,5) ->(0,0)(5,0) [linestyle=dotted](1,0)(1,5) [linestyle=dotted](2,0)(2,5) [linestyle=dotted](3,0)(3,5) [linestyle=dotted](4,0)(4,5) [linestyle=dotted](0,1)(5,1) [linestyle=dotted](0,2)(5,2) [linestyle=dotted](0,3)(5,3) [linestyle=dotted](0,4)(5,4)

Public test cases
  • Input

    5 1.0 0.5 -3.0
    0.0 1.0 0.0
    1.0 -3.0 9.0
    -1.0 1.0 2.0
    1.0 0.0 0.0
    -2.0 -1.0 10.0
    
    4 -1.0 -2.0 -4.0
    1.0 0.0 1.0
    -1.0 0.0 1.0
    0.0 1.0 1.0
    0.0 -1.0 1.0
    
    3 1.23 -4.56 7.89
    42.42 -53.53 64.64
    -98.98 76.76 54.54
    23.23 45.45 10.01
    
    

    Output

    2.000
    -1.000
    9.864
    
  • Information
    Author
    Víctor Martín
    Language
    English
    Official solutions
    C++
    User solutions
    C++