#P16191. [COI 2018] Svjetlost 光
[COI 2018] Svjetlost 光
Background
3 s, 1024 MB.
Problem Description
On the plane, suppose we have a convex polygon , and we place a light source outside the polygon. Then it will illuminate some edges of the polygon: if and are two adjacent vertices of the polygon, then the edge is illuminated if and only if the area of triangle is non-zero, and this edge does not intersect the interior of the polygon. The brightness of the polygon is defined as the sum of the lengths of the illuminated edges, and the maximum brightness of the polygon means the maximum brightness we can obtain by choosing the best position of the light source . The distance from point to the polygon can be arbitrary, and the coordinates of do not have to be integers.

Figure 4: The polygons and in the second sample, with the optimal brightness marked.
Given a convex polygon with vertices in order . The polygon changes over operations: in the -th operation, we delete one existing vertex to obtain a new polygon . More precisely, the vertices of polygon are the vertices of that have not been deleted yet, and their order is the same as in the original polygon . It can be seen that each polygon is still convex.
Please compute the maximum brightness of the initial polygon and of each resulting polygon .
Input Format
The first line contains a positive integer , the number of vertices of the initial polygon . The next lines each contain two integers and , the coordinates of vertex . Then a line contains an integer , the number of changes. The next lines each contain an integer , meaning that in the -th operation we delete vertex . It is guaranteed that the vertices of polygon are given in counterclockwise order, there are no consecutive parallel edges, and all deletion indices are pairwise distinct.
Output Format
Output lines. The first line outputs the maximum brightness of the initial polygon . For line , output the maximum brightness of polygon after the -th change. The absolute or relative error is allowed to be at most compared to the standard answer.
4
0 0
10 0
10 10
0 10
1
2
20.000000
24.142136
6
2 2
4 0
6 0
8 2
8 4
2 4
3
1
4
3
10.828427
11.300563
10.944272
11.656854
Hint
Subtasks
::cute-table{three} |ID|Score|Constraints| |:-:|:--:|:--------:| |||| |||| |||| |||, and for all we have | ||||
Translation source: GPT 4.1 mini.
Translated by ChatGPT 5