This page is still under construction.

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

Forest Highway

Time limit1sMemory limit256 MB

Summary
Compute the area of the part of a simple polygon lying at distance at least d from a given infinite line.
Level

Medium6 of 10

Topics
Geometry
Solved
No attempts yet

Problem

The Slovak government is building a highway from Bratislava to Kosice. The road crosses a forest where many animals live. Gizela the frog, queen of the animals, wants to work out what the highway does to them. The road is noisy, so no animal lives closer than distance dd to it. Gizela wants to know how much habitable land is left. If too little is left, she has to find a new forest for her kingdom.

You are given a description of the forest and the highway. The forest is a simple polygon, so no two of its sides cross. The highway is an infinite straight line of width zero. You are also given the safe distance dd. Compute the area of the habitable part of the forest, that is, the part whose distance to the highway is at least dd.

A drawing of the input of the first example.

Input

The first line contains one integer NN, the number of vertices of the polygon (3≤N≤2 0003 \le N \le 2\,000).

Each of the next NN lines contains two real numbers xix_i and yiy_i, meaning that the ii-th vertex of the polygon is (xi,yi)(x_i, y_i). The vertices are given in order along the boundary, either clockwise or counterclockwise.

The next line contains four real numbers xax_a, yay_a, xbx_b, yby_b. The highway is the line through the two distinct points (xa,ya)(x_a, y_a) and (xb,yb)(x_b, y_b).

The last line contains one positive real number dd, the safe distance.

Every real number in the input is at most 1 0001\,000 in absolute value and has at most 4 digits after the decimal point.

Output

Print the area of the habitable part of the forest on one line, rounded to the nearest multiple of 0.00010.0001 and written with exactly 4 digits after the decimal point.

Examples2

  1. Example 1

    Input
    7
    0.0 0.0
    2.0 4.0
    4.0 0.0
    5.0 5.0
    1.0 6.0
    1.0 4.0
    -1.0 3.0
    -2.0 4.0 6.0 1.0
    0.6
    
    Expected output
    13.0828
    
  2. Example 2

    Input
    4
    0.0000 0.0000
    10.0000 0.0000
    10.0000 10.0000
    0.0000 10.0000
    0.0000 5.0000 10.0000 5.0000
    2.0000
    
    Expected output
    60.0000