luogu#P9845. [ICPC2021 Nanjing R] Paimon Polygon
[ICPC2021 Nanjing R] Paimon Polygon
题目描述
Paimon just puts distinct points on the plane, one of which is a special point , and denote the group of remaining points as .
We call a point set , if and only if and all the points from lie exactly on the convex hull built from , with no three points lying on the same line.
You should divide into two sets and so that:
- .
- .
- .
- The point set is a , and denote its convex hull as .
- The point set is a , and denote its convex hull as .
- The outlines(edges) of and only intersect at point . That is, only one point satisfies that it lies both on the outlines of and .
Please help Paimon to maximize the sum of the perimeters of these two convex hulls. That is, find a valid division and which maximizes $(L(C_{\mathbb{A} \cup \{O\}}) + L(C_{\mathbb{B} \cup \{O\}}))$, where means the perimeter of that polygon.
输入格式
There are multiple test cases. The first line of the input contains an integer indicating the number of test cases. For each test case:
The first line contains one integer () indicating the number of points in .
For the following lines, the -th line contains two integers and (, ) indicating the location of the -th point in .
It's guaranteed that the points given in the same test case are pairwise different. However, there may be three points lying on the same line.
It's also guaranteed that the sum of of all test cases will not exceed .
输出格式
For each test case output one line containing a number indicating the maximum total perimeter. If there does not exist a valid division output 0
instead.
Your answer will be accepted if the relative or absolute error is less than .
题目大意
题目描述
派蒙在平面上放置了个互异的点,其中有一特殊点,并记其余点为。
我们称一个点集 为,当且仅当点集中点的个数大于等于3()且中的所有点位于构成的凸包上,且任意三点不共线。
你需要将划分为两个集合 和,使其满足
-
.
-
.
-
.
-
点集 是 ,并记它的凸包为。
-
点集 是 ,并记它的凸包为 。
-
和 的轮廓 仅在 相交。 这也就是说,仅有点既在的轮廓上,又在的轮廓上。
请协助派蒙计算出这两个凸包周长之和的最大值。 这也就是说,找到一个合法的划分方案 和 ,使得 $(L(C_{\mathbb{A} \cup \{O\}}) + L(C_{\mathbb{B} \cup \{O\}}))$最大,其中代表多边形的周长。
输入格式
多组测试数据,第一行给出数据组数 。
第一行给出一个整数 () ,表示 中点的个数。
接下来行,第行 包含两个整数 和 (, ) 表示 中第 个点的坐标。
保证同一组测试数据中的点互异,但可能存在三点共线。
保证 所有测试数据中之和不超过 .
输出格式
每组测试数据单起一行输出一个整数,表示两个凸包的周长之和的最大值。如不存在合法的划分方案,输出0
。
与标准答案的相对或绝对误差小于 的答案会被视作正确答案。
3
4
0 3
3 0
2 3
3 2
5
4 0
5 -5
-4 -2
1 -2
-5 -2
4
0 1
1 0
0 2
1 1
17.2111025509
36.6326947621
0.0000000000
提示
A valid division (left) and an invalid division (right) of the first sample test case are shown below.