#P9568. [SDCPC 2023] Computational Geometry

[SDCPC 2023] Computational Geometry

题目描述

Given a convex polygon PP with nn vertices, you need to choose three vertices of PP, denoted as aa, bb and cc in counter-clockwise order. There must be exactly kk edges from bb to cc in counter-clockwise order (that is to say, aa is not an endpoint of these kk edges).

Consider cutting through PP with segment abab and acac. Let QQ be the polygon consisting of abab, acac and the kk edges between bb and cc. It's easy to see that this polygon has (k+2)(k + 2) edges.

Find the maximum possible area of QQ.

Note that abab and acac can overlap with edges of PP.

输入格式

There are multiple test cases. The first line of the input contains an integer TT indicating the number of test cases. For each test case:

The first line contains two integers nn and kk (3n1053 \le n \le 10^5, 1kn21 \le k \le n-2) indicating the number of vertices of the convex polygon PP and the number of edges from bb to cc in counter-clockwise order.

For the following nn lines, the ii-th line contains two integers xix_i and yiy_i (109xi,yi109-10^9 \le x_i, y_i \le 10^9) indicating the xx and yy coordinate of the ii-th vertex of the convex polygon PP. Vertices are given in counter-clockwise order. It's guaranteed that the area of the convex polygon is positive, and there are no two vertices with the same coordinate. It's possible that three vertices lie on the same line.

It's guaranteed that the sum of nn of all test cases will not exceed 10510^5.

输出格式

For each test case output one line containing one real number indicating the maximum possible area of QQ. Your answer will be considered correct if its relative or absolute error is less than 10910^{-9}.

3
3 1
0 0
1 0
0 1
8 3
1 2
3 1
5 1
7 3
8 6
5 8
3 7
1 5
7 2
3 6
1 1
3 1
7 1
8 1
5 6
4 6

0.500000000000
26.500000000000
20.000000000000

提示

For the first sample test case, QQ is the whole triangle. Its area is 0.50.5.

The second and third sample test case are shown below.