Under construction

Still being built. Things may change

Simi Circles

Interview

Time limit1sMemory limit1024 MB

Summary
Given circles where each one overlaps only its neighbors in the list, find the total area their union covers in each scenario.
Level

Medium4 of 10

Topics
Geometry, Math, Implementation
Solved
No attempts yet

Problem

Arup has a step-daughter, Simi, at home, so he is often in charge when she swims with her friends. When she finishes, Simi runs into the house without fully drying herself. As she hurries through the house to the bathroom, she leaves water drops on the floor.

Arup's wife, Anita, blames him for not watching the kids closely and making sure they dried off before entering. Anita says the wood was ruined by water damage. Arup knows that not all of the wood is ruined, so he only wants to take responsibility for the area of the wood floor that has water on it.

When Simi runs through the house, each drop hits the ground and forms a perfect circle. She runs fast enough that each drop intersects at most the previous drop and no others. Sometimes a drop does not intersect the previous drop at all. So each drop can intersect at most two drops: the one before it and the one after it. Each drop (circle) covers some area of the wood floor. No circle is completely covered by another circle.

Given a list of circles, where each circle may only intersect the previous circle and the next circle in the list, find the total area covered by all the circles.

Input

The first line contains a single positive integer nn (1≤n≤1001 \le n \le 100), the number of Simi circle scenarios. Each scenario follows.

The first line of each scenario contains a single integer cc (1≤c≤1001 \le c \le 100), the number of drops in that scenario. The next cc lines describe the drops in the order they occurred, one drop per line. Each line contains exactly three real numbers separated by single spaces: xx (−3000<x<3000-3000 < x < 3000), yy (−3000<y<3000-3000 < y < 3000), and rr (0<r<100 < r < 10). These are the x and y coordinates of the drop's center (in cm) and the drop's radius (in cm).

Output

For each scenario, print Set #i: where ii is the scenario number starting at 1, followed by the total area covered by all the drops, as a positive real number rounded to 2 decimal places, in cm^2. For example, an area of 31.674 cm^2 is printed as 31.67, and an area of 31.675 cm^2 is printed as 31.68.

Print a blank line after the output for each scenario. Follow the format shown in the sample output.

Hint

If you need π\pi in your program, use the value 3.1415926535898.

Examples1

  1. Example 1

    Input
    3
    2
    0 0 1
    0 2 1
    2
    0 0 5
    6 0 5
    1
    0.1 0.1 0.1
    
    Expected output
    Set #1: 6.28
    
    Set #2: 134.71
    
    Set #3: 0.03