#P16859. [GKS 2021 #F] Star Trappers

    ID: 19186 远端评测题 3000ms 1024MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>计算几何2021Special Judge枚举Google Kick Start

[GKS 2021 #F] Star Trappers

Problem Description

John and Ada are sitting on the grass above a small hill. It is midnight and the sky is full of stars. The sky looks like a 22D plane from so far away and the stars look like points on that plane. Ada loves blue stars and suddenly she notices one, while all the other stars in the sky are white. She loves the blue star so much that she wants to trap it. And she asks John for help.

Ada will tell John the position of the blue star and he has to trap it. To trap it, John has to draw a polygon in the sky with his buster sword, so that the blue star is strictly inside the polygon (not on the border of the polygon) and the polygon has the smallest possible perimeter. The vertices of the polygon must be the white stars.

Even though John is super awesome, he needs your help. Given the positions of the white stars and the blue star, you need to find out whether John can trap the blue star and if he can, also find the minimum length of the perimeter of the polygon he will use.

Input Format

The 11st line of the input gives the number of test cases, TT. TT test cases follow.

For each test case, the 11st line contains an integer NN, it denotes the number of white stars in the sky.

The next NN lines will each contain 22 integers, XiX_i and YiY_i. The ii-th pair of integers denotes the xx and yy coordinates of the ii-th star in the sky.

After these NN lines, there will be 11 last line, which will contain 22 integers, XsX_s and YsY_s, which denote the xx and yy coordinates of the blue star.

Output Format

For each test case, output 11 line containing Case #xx: yy, where xx is the test case number (starting from 11) and yy is the minimum length of the perimeter of the polygon drawn to trap the shooting star. If it is impossible for John to draw a polygon that traps the star, then yy should be IMPOSSIBLE.

yy will be considered correct if it is within an absolute or relative error of 10610^{-6} of the correct answer.

2
2
0 0
5 0
2 2
3
0 0
5 0
0 5
1 1
Case #1: IMPOSSIBLE
Case #2: 17.071068

Hint

In the first test case we have only two white stars, so we cannot draw any polygons.

In the second test case we have three white stars, so we can draw only one polygon (a triangle), as shown in the picture below. It turns out that we are able to catch the blue star in this polygon. The length of the perimeter of this polygon is 5+5+5217.0710685 + 5 + 5\sqrt{2} \approx 17.071068.

:::align{center} :::

Limits

Memory limit: 11 GB.

1T1001 \le T \le 100.

0Xi,Yi1060 \le X_i, Y_i \le 10^6, for all ii.

0Xs,Ys1060 \le X_s, Y_s \le 10^6.

No two stars (including the blue star) will have the same position.

Test Set 11

1N101 \le N \le 10.

Test Set 22

1N451 \le N \le 45.

Test Set 33

For at most 1010 test cases:

1N3001 \le N \le 300.

For the remaining test cases:

1N601 \le N \le 60.