Star Trappers
Memory limit1024 MB
Find the minimum perimeter of a polygon with white-star vertices that strictly contains the blue star, or report IMPOSSIBLE.
- Level
Medium7 of 10
- Topics
- Geometry, Dynamic programming, Sorting
- Solved
- No attempts yet
문제
John and Ada are sitting on the grass above a small hill. It is midnight and the sky is full of stars. From so far away, the sky looks like a 2D plane, and the stars look like points on that plane. Ada loves blue stars. She suddenly notices one while all the other stars in the sky are white. She wants to trap it, so she asks John for help.
Ada tells John the position of the blue star, and John has to trap it. To trap it, John draws a polygon in the sky with his buster sword so that the blue star is strictly inside the polygon (not on its border). The polygon must have the smallest possible perimeter. The vertices of the polygon must be white stars.
Given the positions of the white stars and the blue star, find out whether John can trap the blue star. If he can, find the minimum perimeter of the polygon he uses.
입력
The first line contains , the number of test cases. Each test case starts with an integer , the number of white stars. The next lines each contain two integers and , the coordinates of the -th white star. The last line of each test case contains two integers and , the coordinates of the blue star.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the minimum perimeter of the polygon that traps the blue star. If John cannot trap the star, output IMPOSSIBLE as . An answer is accepted if its absolute or relative error is within .
제한
- .
- for all .
- .
- No two stars, including the blue star, have the same position.
힌트
In the first test case there are only two white stars, so no polygon can be drawn. In the second test case there are three white stars, so only one polygon (a triangle) can be drawn. As shown in the picture below, the blue star lies inside this triangle. Its perimeter is .
