#P3268. XOR Area Union of Non-Intersecting Circles

    ID: 16525 Type: Default 1000ms 256MiB

XOR Area Union of Non-Intersecting Circles

XOR Area Union of Non-Intersecting Circles

In a Cartesian coordinate system, you are given N circles. It is known that any two circles do not intersect, meaning that for any two circles, the relationship is either disjoint or one circle is contained in the other.

The task is to compute the XOR area union of these circles. The XOR area union is defined as follows:

If a region is covered by an odd number of circles, its area is counted; if it is covered by an even number of circles, it is not counted.

In mathematical terms, if a point is contained in exactly an odd number of circles, then its area contributes to the answer. For example, for a single circle with radius r the area is \(\pi r^2\). If one circle is completely inside another, then the inner circle’s area (which is covered twice) is subtracted from the outer circle’s area, resulting in an XOR area union of \(\pi r_{\text{outer}}^2 - \pi r_{\text{inner}}^2\).

inputFormat

The first line contains an integer N (\(1 \le N \le 10^5\)), representing the number of circles.

Each of the next N lines contains three numbers: x, y and r, where (x, y) denote the coordinates of the circle's center and r is its radius. It is guaranteed that any two circles do not intersect, i.e., for any two circles, they are either disjoint or one is completely contained within the other.

outputFormat

Output a single floating-point number representing the XOR area union of the given circles.

sample

1
0 0 1
3.141592653589793