#P3219. Union Area of Axis-Aligned Right Isosceles Triangles
Union Area of Axis-Aligned Right Isosceles Triangles
Union Area of Axis-Aligned Right Isosceles Triangles
Given N right isosceles triangles on a 2D plane, where each triangle's two perpendicular legs are parallel to the coordinate axes and the hypotenuse runs from the upper-left to the lower-right, compute the total area covered by the union of these triangles.
Each triangle is described by three non-negative integers \( (x, y, d) \). Its three vertices are \( (x, y) \), \( (x+d, y) \), and \( (x, y+d) \). Note that the area of an individual triangle is \( \frac{d^2}{2} \); however, since triangles may overlap, overlapping regions should be counted only once.
Note: All formulas are expressed in \( \LaTeX \) format.
inputFormat
The first line contains an integer \(N\) (\(1 \le N \le 1000\)), the number of triangles.
Each of the next \(N\) lines contains three non-negative integers \(x, y, d\) separated by spaces.
outputFormat
Output a single number representing the total area covered by the union of the given triangles. The answer should be printed with one decimal place.
sample
1
0 0 2
2.0