Shortest Fence
Time limit1sMemory limit128 MB
Enclose up to 100 disjoint circles with the shortest closed fence and print its length rounded to five decimals.
Problem
Your garden holds trees and goats. To keep the goats off the trees you decide to build one fence that encloses every tree, and you want that fence to be as short as possible.
Seen from above, each tree is a circle in the plane. The fence is a closed curve that keeps every tree inside it, and it touches some or all of the trees. Find the smallest possible length of such a fence.
Input
The first line contains the number of test cases . ()
Each test case is given in lines. The first line contains the number of trees in the garden . () Each of the next lines contains three integers , and separated by spaces. and are the coordinates of the centre of a tree and is its radius.
, and are integers between and , inclusive. No two trees in the input touch or overlap.
Output
For each test case, print on one line the minimum length of a fence that surrounds every tree. Round the value at the sixth decimal place and always print five digits after the decimal point.