This page is still under construction.

Parts of this page are still being built. What you see may change.

Safe Zone

Time limit1sMemory limit128 MB

Summary
Given disjoint circles, find the shortest closed fence enclosing all of them, which equals the convex hull perimeter plus the circumference of one circle.
Level

Medium6 of 10

Topics
Geometry, Divide and conquer
Solved
No attempts yet

Problem

Yeonjong wants to install a new surveillance system in his yard.

There are NN circular objects in the yard. Along the boundary of the surveillance system he wants to build a high-voltage fence. The safe zone enclosed by the fence must be connected as a single region, and every object must lie inside this safe zone. No two objects overlap or touch. Write a program that minimizes the total length of the fence under these conditions.

Input

The first line contains the number of test cases CC (0≤C≤1000 \le C \le 100). Each test case begins with a line containing the number of objects NN (0<N≤250 < N \le 25). The next NN lines each contain three numbers xix_i, yiy_i, and rir_i: the ii-th object is a circle centered at (xi,yi)(x_i, y_i) with radius rir_i (∣xi∣≤100|x_i| \le 100, ∣yi∣≤100|y_i| \le 100, 0<ri≤1000 < r_i \le 100).

Output

For each test case, print on its own line the minimum length of a fence that encloses all objects, rounded to exactly 10 digits after the decimal point.

Examples1

  1. Example 1

    Input
    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
    
    Expected output
    22.2831853072
    17.6761051635
    25.4247779608