Detectors

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 16M

Problem type

You've just escaped from your cold, dark, damp jail cell, and you still have no idea who you are or how you came to be here—but one thing you do know is that you're not out of harm's way yet. It still remains to escape from the complex. This is not easy, because even though you are gifted with the power of invisibility (being a quantum being and all) the guards have "quantum detectors" that will find you regardless. By now you have gathered that a secret, illicit organization is in operation here, which must obtain its technology from the black market. For this reason, standardization is a laughable concept, and not all of these detectors are equally sensitive—each can detect quantum beings who are less than a certain distance away, and the distance varies from detector to detector.

As you make your way across the grounds of what you now know to be the Stronghold of the Order of the Brotherhood of the Flying Hat, you notice that the boundaries of detection of the various guards' detectors often overlap, and wonder what is the total length of the "boundary"—the set of all points on the ground (making this a two-dimensional problem, thank goodness) which are not within range of any detector, but from which it is possible to end up within range of at least one detector by making an infinitesimal step towards it.

Once you have successfully escaped from the Stronghold, you realize that you somehow still remember how to code in A++, and that your Quantum Reality Protocol has a built-in A++ compiler. Before long, you have determined the answer to your question…

Problem Statement

There are n guards. Guard number i is located at coordinates (x_i,y_i) and his/her detector has a radius of r_i. Determine the total length of the boundary, as specified above.

Input Specification

The first line of input will contain the integer n (0 < n \le 1\,000).

Subsequent lines will contain three real numbers: x_i, y_i, and r_i for one of the guards (-1\,000 \le x_i, y_i \le +1\,000; 0 < r_i \le 100)

You may assume that no two guards are standing at the same location, for that is clearly a physical impossibility.

Output Specification

The total length of the boundary. Your answer must match ours with a relative or absolute error of at most 10^{-6}.

Sample Input

4
0 0 100
0 1 98
150 0 100
200 200 10

Sample Output

1030.375215

Comments

There are no comments at the moment.