Under construction

Still being built. Things may change

Dominoes

Time limit2sMemory limit1024 MB

Summary
Given n dominoes that fall left with heights l_i, find for each starting domino the area of the union of quarter circles that topple.
Level

Hard8 of 10

Topics
Stack, Dynamic programming, Geometry
Solved
No attempts yet

Statement

Pixar is preparing to premiere its next animated film, Elemental, at the 2023 Cannes Film Festival. One scene needs to be re-rendered. The scene has nn dominoes in a straight line. When one of them falls, it knocks over the dominoes after it in a chain. The festival is less than a month away, so Pixar asks you to write a program that computes the cost of re-rendering the scene for each choice of the initial domino.

To keep the calculation simple, treat each domino as a line segment with no width on the coordinate axis. The dominoes fall to the left. They are numbered from left to right, and domino ii has height lil_i and is located at xix_i. The cost of re-rendering is the area of the moving part of the scene, which is the union of the quarter circles traced by the dominoes that fall. Falling areas may overlap, and any overlapped area is counted only once. The picture shows the fall when domino 5 is the initial domino.

Input

The first line contains a positive integer nn, the number of dominoes. Each of the next nn lines contains two integers xix_i and lil_i, the location and the height of domino ii. The dominoes are given from left to right, so xi<xi+1x_i < x_{i+1}. It is guaranteed that n≤200000n \le 200000 and 1≤xi,li≤1091 \le x_i, l_i \le 10^9.

Output

Output nn lines. The ii-th line contains the cost of re-rendering the scene when domino ii is the initial falling domino. Every number must have an absolute or relative error of at most 10−610^{-6}.

Examples1

  1. Example 1

    Input
    7
    2 2
    5 3
    9 5
    12 1
    13 5
    14 2
    16 3
    
    Expected output
    3.141592654
    7.068583471
    24.659773696
    0.785398163
    42.250963921
    44.164186876
    49.714124052