favorite We need a little bit of your help to keep things running, click on this banner to learn more

April 16 Contest

Inscribed Circle

The circle is inscribed in a polygon, if it has a point of contact with each side of the polygon.

Determine is it possible to inscribe a circle into a given convex polygon, and if the answer is positive, find the coordinates of its center and radius.


The first line contains the number of vertices of the polygon n (3n8). The following n lines contain the coordinates of the vertices of the polygon in order circumvent anti-clockwise, each line contains two integers: xi and yi that do not exceed 1000 by absolute value.


If an inscribed circle in polygon exist, print in the first line the word YES, otherwise print the word NO. If answer is yes, print in the second row the coordinates of the circle center and its radius. Print the answer with accuracy 10-6.

Time limit 1 second
Memory limit 128 MiB
Input example #1
0 0
1 0
1 1
0 1
Output example #1
0.500000 0.500000 0.500000
Input example #2
0 0
1 0
1 2
0 2
Output example #2
Source 2008 XIX regional school olympiad in informatics, Vologda, Problem C