This page is still under construction.

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

Fireflies

Time limit1sMemory limit128 MB

Summary
Choose a shutter time that minimizes the side length of an axis-aligned square holding all fireflies moving at constant velocities.
Level

Medium6 of 10

Topics
Binary search, Geometry
Solved
No attempts yet

Problem

There are nn fireflies moving in a plane. Firefly ii starts at (xi,yi)(x_i, y_i) and moves with constant velocity (ai,bi)(a_i, b_i). After time tt its position is (xi+t⋅ai,yi+t⋅bi)(x_i + t \cdot a_i, y_i + t \cdot b_i).

You want to capture every firefly in one axis-aligned square photo frame. You may choose the shutter time tt freely. Find the minimum side length dd of a square, with sides parallel to the axes, that can contain all fireflies at some time tt.

Input

The first line contains an integer nn (1≤n≤100 0001 \le n \le 100\,000).

Each of the next nn lines contains four integers xi,yi,ai,bix_i, y_i, a_i, b_i (−106≤xi,yi,ai,bi≤106-10^6 \le x_i, y_i, a_i, b_i \le 10^6). (xi,yi)(x_i, y_i) is the starting position and (ai,bi)(a_i, b_i) is the velocity vector.

Output

Print one real number dd, the minimum possible side length of an axis-aligned square that covers all fireflies at some time tt. Your answer is accepted if it differs from the correct value by at most 10−310^{-3} in absolute or relative error.

Hint

At any time, compute the span of xx coordinates and the span of yy coordinates; the needed side length is the larger of the two. The objective over time is convex, so ternary search works.

Examples4

  1. Example 1

    Input
    4
    4 0 -1 1
    1 6 -1 -2
    -1 -5 0 2
    -1 -1 1 1
    
    Expected output
    3.00000000000000000000
    
  2. Example 2

    Input
    1
    5 3 0 0
    
    Expected output
    0.00000000000000000000
    
  3. Example 3

    Input
    2
    0 0 1 0
    0 0 -1 0
    
    Expected output
    0.00000000000000000000
    
  4. Example 4

    Input
    3
    0 0 0 0
    10 0 0 0
    0 5 0 0
    
    Expected output
    10.00000000000000000000