#P4529. [SCOI2003] 切割多边形
[SCOI2003] 切割多边形
Description
We wish to obtain a convex -gon, .
Initially, you have an rectangle; that is, its four corner coordinates are . Each time, you may choose a straight line to cut the current shape into two parts and keep one part (discard the other). The length of a cut is defined as the length of the portion of this line that lies inside the polygon.
Find the minimal total length of all cutting lines.
Below is an example; we need to obtain the polygon in the middle.

Cut along lines respectively to obtain the quadrilateral in the middle.
Input Format
The first line contains two integers .
The second line contains an integer , and each of the following lines contains two integers , which are the vertex coordinates given in clockwise order.
It is guaranteed that the polygon is convex, no three points are collinear, and the input is valid.
Output Format
Output a single line with the minimal total length of the cutting lines, rounded to decimal places. An error of is allowed.
100 100
4
80 80
70 30
20 20
20 80
312.575
Hint
The sample corresponds to the example shown in the figure.
Translated by ChatGPT 5
京公网安备 11011102002149号