#P16191. [COI 2018] Svjetlost 光

    ID: 18104 远端评测题 3000ms 1024MiB 尝试: 0 已通过: 0 显示难度暂无评定 上传者: 标签>2018Special JudgeCOI(克罗地亚)

[COI 2018] Svjetlost 光

Background

3 s, 1024 MB.

Problem Description

On the plane, suppose we have a convex polygon PP, and we place a light source TT outside the polygon. Then it will illuminate some edges of the polygon: if AA and BB are two adjacent vertices of the polygon, then the edge ABAB is illuminated if and only if the area of triangle TABTAB 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 TT. The distance from point TT to the polygon can be arbitrary, and the coordinates of TT do not have to be integers.

Figure 4: The polygons P,P1,P2P, P_1, P_2 and P3P_3 in the second sample, with the optimal brightness marked.

Given a convex polygon PP with vertices in order A1,A2,…,AnA_1, A_2, \ldots, A_n. The polygon changes over qq operations: in the jj-th operation, we delete one existing vertex to obtain a new polygon PjP_j. More precisely, the vertices of polygon PjP_j are the vertices of PP that have not been deleted yet, and their order is the same as in the original polygon PP. It can be seen that each polygon PjP_j is still convex.

Please compute the maximum brightness of the initial polygon PP and of each resulting polygon P1,P2,…,PqP_1, P_2, \ldots, P_q.

Input Format

The first line contains a positive integer nn, the number of vertices of the initial polygon PP. The next nn lines each contain two integers xjx_j and yj (−109≤xj,yj≤109)y_j\ (-10^9\le x_j, y_j \le 10^9), the coordinates of vertex AjA_j. Then a line contains an integer q (0≤q≤n−3)q\ (0 \le q \le n - 3), the number of changes. The next qq lines each contain an integer kj (1≤kj≤n)k_j\ (1 \le k_j \le n), meaning that in the jj-th operation we delete vertex AkjA_{k_j}. It is guaranteed that the vertices of polygon PP are given in counterclockwise order, there are no consecutive parallel edges, and all deletion indices kjk_j are pairwise distinct.

Output Format

Output q+1q + 1 lines. The first line outputs the maximum brightness of the initial polygon PP. For line j (1≤j≤q)j\ (1 \le j \le q), output the maximum brightness of polygon PjP_j after the jj-th change. The absolute or relative error is allowed to be at most 10−510^{−5} 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| |:-:|:--:|:--------:| |11|1212|n≤100n\le 100| |22|1414|n≤2000n\le 2000| |33|1414|n≤100 000,q=0n\le 100\,000,q=0| |44|2929|n≤100 000n\le 100\,000, and for all j=1,…,q−1j = 1,\ldots, q − 1 we have kj<kj+1k_j < k_{j+1}| |55|3131|n≤100 000n\le 100\,000|

Translation source: GPT 4.1 mini.

Translated by ChatGPT 5