eolymp
bolt
Try our new interface for solving problems
Problems

Room Service

Room Service

You are working for a company designing cute, funny robot vacuum cleaners. At a high level, the robots’ behavior is divided into three modes: \begin{enumerate} \item Exploration \item Vacuuming \item Rampant Killing \end{enumerate} Unfortunately, while consumer testing shows that the last two modes are working perfectly, the exploration mode still has bugs. You’ve been put in charge of debugging. At the beginning of the exploration mode, the robot is placed into a convex polygonal room. It has sensors that should tell it where all the walls are. Your job is to write a program that verifies that these readings are correct. To do this, the robot needs to physically touch every wall in the room. Your problem is this: given the shape of a convex polygonal room with N walls and a starting point \textbf{P} inside it, determine the shortest route that touches each wall and then returns to \textbf{P}. Touching a corner counts as touching both incident walls. \InputFile Each test case starts with a line containing the number of vertices \textbf{N} of the polygon (\textbf{3} ≤ \textbf{N} ≤ \textbf{100}) and the integer coordinates \textbf{P_x} and \textbf{P_y} of the robot’s starting point (\textbf{-10000} ≤ \textbf{P_x}, \textbf{P_y} ≤ \textbf{10000}). This is followed by \textbf{N} lines, each containing two integers \textbf{x}, \textbf{y} (\textbf{-10000} ≤ \textbf{x}, \textbf{y} ≤ \textbf{10000}) defining a vertex of the polygon. Vertices are given in counterclockwise order, all interior angles are less than \textbf{180} degrees, the polygon does not self-intersect, and the robot’s starting point is strictly inside the polygon. \OutputFile For each test case, display the case number and the length of the desired route, accurate to two decimal places.
Time limit 3 seconds
Memory limit 256 MiB
Input example #1
4 0 0
-1 -1
1 -1
1 1
-1 1
3 10 1
0 0
30 0
0 20
Output example #1
Case 1: 5.66
Case 2: 36.73
Source ACM-ICPC World Finals 2012