Forest Highway
Time limit1sMemory limit256 MB
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 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 . Compute the area of the habitable part of the forest, that is, the part whose distance to the highway is at least .

A drawing of the input of the first example.
Input
The first line contains one integer , the number of vertices of the polygon ().
Each of the next lines contains two real numbers and , meaning that the -th vertex of the polygon is . The vertices are given in order along the boundary, either clockwise or counterclockwise.
The next line contains four real numbers , , , . The highway is the line through the two distinct points and .
The last line contains one positive real number , the safe distance.
Every real number in the input is at most 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 and written with exactly 4 digits after the decimal point.