#P9702. [GDCPC 2023] Computational Geometry

[GDCPC 2023] Computational Geometry

题目描述

Given a convex polygon PP with nn vertices, you need to choose two vertices of PP, so that the line connecting the two vertices will split PP into two smaller polygons QQ and RR, both with positive area.

Let d(Q)d(Q) be the diameter of polygon QQ and d(R)d(R) be the diameter of polygon RR, calculate the minimum value of (d(Q))2+(d(R))2(d(Q))^2 + (d(R))^2.

Recall that the diameter of a polygon is the maximum distance between two points inside or on the border of the polygon.

输入格式

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 an integer nn (4n5×1034 \le n \le 5 \times 10^3) indicating the number of vertices of the convex polygon PP.

For the following nn lines, the ii-th line contains two integers xix_i and yiy_i (0xi,yi1090 \le x_i, y_i \le 10^9) indicating 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 5×1035 \times 10^3.

输出格式

For each test case output one line containing one integer indicating the answer.

2
4
1 0
2 0
1 1
0 0
6
10 4
9 7
5 7
4 5
6 4
9 3
4
44

提示

The first sample test case is shown as follows. The diameter of smaller polygons are marked by red dashed segments. In fact, (1,0)(1, 0) and (1,1)(1, 1) are the only pair of vertices we can choose in this test case. You can't choose (0,0)(0, 0) and (2,0)(2, 0), or (0,0)(0, 0) and (1,1)(1, 1), because they can't split PP into two smaller polygons both with positive area.

The second sample test case is shown as follows. The diameter of smaller polygons are marked by red dashed segments.