eolymp
bolt
Try our new interface for solving problems
Problems

Kitchen Robot

Kitchen Robot

Robots are becoming more and more popular. They are used nowadays not only in manufacturing plants, but also at home. One programmer with his friends decided to create their own home robot. As you may know most programmers like to drink beer when they gather together for a party. After the party there are a lot of empty bottles left on the table. So, it was decided to program robot to collect empty bottles from the table. The table is a rectangle with the length $l$ and width $w$. Robot starts at the point $(x_r, y_r)$ and $n$ bottles are located at points $(x_i, y_i)~(1 \le i \le n)$. To collect a bottle robot must move to the point where the bottle is located, take it, and then bring to some point on the border of the table to dispose it. Robot can hold only one bottle at the moment and for simplicity of the control program it is allowed to release bottle only at the border of the table. \includegraphics{https://static.e-olymp.com/content/17/17a74c81566624ed3d69bb72090a44e90e610661.jpg} You can assume that sizes of robot and bottles are negligibly small (robot and bottles are points), so the robot holding a bottle is allowed to move through the point where another bottle is located. One of the subroutines of the robot control program is the route planning. You are to write the program to determine the minimal length of robot route needed to collect all the bottles from the table. \InputFile The first line contains two integer numbers $w$ and $l~(2 \le w, l \le 1000)$ --- the width and the length of the table. The second line contains an integer number $n~(1 \le n \le 18)$ --- the number of bottles on the table. Each of the following $n$ lines contains two integer numbers $x_i$ and $y_i~(0 < x_i < w, 0 < y_i < l)$ --- coordinates of the $i$-th bottle. No two bottles are located at the same point. The last line contains two integer numbers $x_r$ and $y_r~(0 < x_r < w, 0 < y_r < l)$ --- coordinates of the robot's initial position. Robot is not located at the same point with a bottle. \OutputFile Print the length of the shortest route of the robot. Your answer should be accurate within an absolute error of $10^{-6}$.
Time limit 1 second
Memory limit 256 MiB
Input example #1
3 4
2
1 1
2 3
2 1
Output example #1
5.60555127546399
Author Fedor Tsarev
Source 2010 ACM NEERC, Northern Subregion, October 30, Problem K