Paimon Polygon

시간 제한2초메모리 제한1024 MB

요약
원점과 함께 각각 엄격한 볼록 다각형을 이루고 원점에서만 만나도록 n개의 점을 두 그룹으로 나누고, 두 다각형 둘레의 합을 최대로 만든다.
난이도

어려움10점 중 8점

유형
기하, 정렬, 그리디, 투 포인터
정답자
아직 제출이 없습니다

문제

Paimon just puts (n+1)(n+1) distinct points on the plane, one of which is a special point O=(0,0)O=(0,0), and denote the group of remaining points as S\mathbb{S}.

We call a point set U\mathbb{U} strict convex set, if and only if ∣U∣≥3|\mathbb{U}| \ge 3 and all the points from U\mathbb{U} lie exactly on the convex hull built from U\mathbb{U}, with no three points lying on the same line.

You should divide S\mathbb{S} into two sets A\mathbb{A} and B\mathbb{B} so that:

  • A∩B=∅\mathbb{A} \cap \mathbb{B}=\emptyset.
  • A∪B=S\mathbb{A} \cup \mathbb{B}=\mathbb{S}.
  • ∣A∣≥2,∣B∣≥2|\mathbb{A}| \ge 2, |\mathbb{B}| \ge 2.
  • The point set A∪O\mathbb{A} \cup \\{O\\} is a strict convex set, and denote its convex hull as C_A∪OC\_{\mathbb{A} \cup \\{O\\}}.
  • The point set B∪O\mathbb{B} \cup \\{O\\} is a strict convex set, and denote its convex hull as C_B∪OC\_{\mathbb{B} \cup \\{O\\}}.
  • The outlines(edges) of C_A∪OC\_{\mathbb{A} \cup \\{O\\}} and C_B∪OC\_{\mathbb{B} \cup \\{O\\}} only intersect at point OO. That is, only one point OO satisfies that it lies both on the outlines of C_A∪OC\_{\mathbb{A} \cup \\{O\\}} and C_B∪OC\_{\mathbb{B} \cup \\{O\\}}.

Please help Paimon to maximize the sum of the perimeters of these two convex hulls. That is, find a valid division A\mathbb{A} and B\mathbb{B} which maximizes (L(C_A∪O)+L(C_B∪O))(L(C\_{\mathbb{A} \cup \\{O\\}}) + L(C\_{\mathbb{B} \cup \\{O\\}})), where L(polygon)L(\text{polygon}) means the perimeter of that 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 one integer nn (4≤n≤5×1054 \le n \le 5 \times 10^5) indicating the number of points in S\mathbb{S}.

For the following nn lines, the ii-th line contains two integers x_ix\_i and y_iy\_i (−109≤x_i,y_i≤109-10^9 \le x\_i, y\_i \le 10^9, (x_i,y_i)≠(0,0)(x\_i, y\_i) \ne (0, 0)) indicating the location of the ii-th point in S\mathbb{S}.

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 nn of all test cases will not exceed 10610^6.

출력

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" (without quotes) instead.

Your answer will be accepted if the relative or absolute error is less than 10−610^{-6}.

힌트

A valid division (left) and an invalid division (right) of the first sample test case are shown below.

예제1

  1. 예제 1

    입력
    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