eolymp
bolt
Try our new interface for solving problems
Problems

Security Zone

Security Zone

The manager of a large security company has to build a new surveillance system for different sites. A site consists of N objects where each object has its own security circle. At the border of the surveillance system a high voltage fence has to be installed. The security zone inside of the fence has to be connected. Furthermore, all objects and their security circles should be inside the security zone. The security circles of different objects will never overlap or touch. Now the manager needs your help. He asks you for the minimal needed fence length. \includegraphics{https://static.e-olymp.com/content/26/26193bd917ef694bd8314b27327f6f3b55f44f33.jpg} \textit{\textbf{Figure 1}} - Illustration of first and second sample input. \InputFile The first line of the input gives the number of test cases \textbf{C} (\textbf{0} ≤ \textbf{C} ≤ \textbf{100}). The first line of each such test case holds the integer \textbf{N}: the number of objects in the current site (\textbf{0} < \textbf{N} ≤ \textbf{25}). Each of the following \textbf{N} lines holds three integers \textbf{x_i}, \textbf{y_i}, and \textbf{r_i} that describe an object. The coordinates of the \textbf{i}-th object and the radius for the needed security circle for this object. (\textbf{|x_i|},\textbf{|y_i|} ≤ \textbf{100}, \textbf{0} < \textbf{r_i} ≤ \textbf{100}) (The center of the security circle around an object is the position of the object itself.) \OutputFile For each test case print one line containing the minimal fence length for this case. Your output should have an absolute or relative error of at most \textbf{10^\{-7\}}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
3
2 2 1
8 2 1
5 6 1
2
6 4 2
2 4 1
4
2 2 2
6 1 1
5 5 2
1 6 1
Output example #1
22.2831853072
17.6761051635
25.4247779608
Source ACM ICPC German Collegiate Programming Contest 2011