#P3219. [HNOI2012] 三角形覆盖问题

    ID: 2268 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>计算几何2012各省省选平衡树湖南枚举,暴力

[HNOI2012] 三角形覆盖问题

Description

In the two-dimensional plane, you are given NN isosceles right triangles (each triangle’s two legs are parallel to the coordinate axes, and the hypotenuse goes from top-left to bottom-right). We use three non-negative integers (x,y,d)(x, y, d) to describe such a triangle. The coordinates of its three vertices are (x,y)(x, y), (x+d,y)(x+d, y), and (x,y+d)(x, y+d). Compute the total area covered by these NN triangles. For example, in the figure below, there are 33 triangles, and the total covered area is 11.011.0.

Input Format

The first line contains a positive integer NN, indicating the number of triangles. Each of the next NN lines contains three space-separated non-negative integers x,y,dx, y, d, describing a triangle whose vertices are (x,y)(x, y), (x+d,y)(x+d, y), and (x,y+d)(x, y+d), where x,y,dx, y, d satisfy 0x,y,d1060 \le x, y, d \le 10^6.

Output Format

Output a single line containing a real number SS, the total area covered by all triangles, with exactly one decimal place. It is guaranteed that S231S \le 2^{31}.

3
1 1 4
2 0 2
3 2 2
11.0

Hint

For 50%50\% of the testdata, 1N5001 \le N \le 500. For 100%100\% of the testdata, 1N1041 \le N \le 10^4.

Translated by ChatGPT 5