Deadline No deadline
Submission limit No limitation

Sign in

Contest 1 2019 - D

Security camera

A store owner wants to install a new security camera inside his store. We treat the store as a two-dimensional convex polygon. The camera has a 90 degree view angle. It is placed on the middle point of the wall connecting the first two vertices in a way such that the borders of the view are given by the two lines that intersect the wall at a 45 degree angle. Can you help the store owner to know how much of the store is visible to the camera?


The following example describes the first sample input. The camera is always place in the middle point of the segment connecting the the first two points in the room. The green area shows area of the store that the camera can see. The answer is the ratio between this green area and the total area of the store.



The first line contains a single integer \(n\) giving the number of vertices in the polygon describing the store.

Then follow \(n\) lines each with two integers \(x, y\) giving the coordinates of those vertices. The vertices are given in counterclockwise order. All internal angles are strictly between 0 and 180 degrees.


  • \(3 \leq n \leq 1000\)
  • \(-10^5 \leq x, y \leq 10^5\)


The ratio between the area visible by the camera and the total area of the store.

The camera is always placed exactly halfway between the first two corners of the room.

The answer should be accurate up to \(10^{-6}\) relative or absolute precision.

Do not worry about formating the output with printf or others, as long as the precision is ok, your answer will be accepted

Sample Test Cases

Sample input 1

Sample output 1

Sample input 2

Sample output 2

Sample input 3

Sample output 3

Max file size: 1.0 MiB
Allowed extensions: .java, .cpp, .py