hdu3265(好题翻译)

译文:
问题描述
Ted拥有一间大房子,这间大房子有一扇很大的窗户。在一个炎炎夏日,Ted突发奇想决定用一些海报来装饰一下这扇窗户(主要还是为了避免窗外路人投来的奇怪眼光)。然而Ted只能找到一些呈矩形的海报。

然而,Ted是一个非常挑剔的家伙。他在每张海报上都找到了一些很丑的(插画),所以在他贴上海报之前,他在每一张海报上都剪下了呈矩形的一部分来把那些碍眼的插画去掉。Ted同时也是一个很粗心的家伙,他在贴海报的时候海报会有重叠。

Ted想要知道窗户被海报覆盖的总面积。
现在这就成了你的任务了。

为了让你的工作轻松一点,我们假设这扇窗户是定义在平面直角坐标系内的一个矩形,窗户的最左下角位于(0,0),最右上角位于(50000,50000)。窗户的边界,海报的边界以及洞洞的边界都是与平面直角坐标系中的x轴(或y轴)平行。

输入
输入包括若干测试点。
每一个测试点第一行是一个整数N (0 < N <= 50000),表示海报的总数,接下来的N行包含8个数 x1, y1, x2, y2, x3, y3, x4, y4,描述每一张海报。(x1, y1) 是海报的左下角, (x2, y2) 是海报的右上角。 (x3, y3) 是海报上被删去的矩形的左下角, (x4, y4) 是海报上被删去的矩形的右上角。保证 0 <= xi, yi <= 50000(i=1…4) 且x1 <= x3 < x4 <= x2, y1 <= y3 < y4 <= y2.

输入由一行0结束

输出
对于每一个测试点,输出单独一行,表示窗户被海报覆盖的总面积。

样例输入
2
0 0 10 10 1 1 9 9
2 2 8 8 3 3 7 7
0

样例输出
56

原文:
Problem Description
Ted has a new house with a huge window. In this big summer, Ted decides to decorate the window with some posters to prevent the glare outside. All things that Ted can find are rectangle posters.

However, Ted is such a picky guy that in every poster he finds something ugly. So before he pastes a poster on the window, he cuts a rectangular hole on that poster to remove the ugly part. Ted is also a careless guy so that some of the pasted posters may overlap when he pastes them on the window.

Ted wants to know the total area of the window covered by posters. Now it is your job to figure it out.

To make your job easier, we assume that the window is a rectangle located in a rectangular coordinate system. The window’s bottom-left corner is at position (0, 0) and top-right corner is at position (50000, 50000). The edges of the window, the edges of the posters and the edges of the holes on the posters are all parallel with the coordinate axes.

Input
The input contains several test cases. For each test case, the first line contains a single integer N (0 < N <= 50000), representing the total number of posters. Each of the following N lines contains 8 integers x1, y1, x2, y2, x3, y3, x4, y4, showing details about one poster. (x1, y1) is the coordinates of the poster’s bottom-left corner, and (x2, y2) is the coordinates of the poster’s top-right corner. (x3, y3) is the coordinates of the hole’s bottom-left corner, while (x4, y4) is the coordinates of the hole’s top-right corner. It is guaranteed that 0 <= xi, yi <= 50000(i=1…4) and x1 <= x3 < x4 <= x2, y1 <= y3 < y4 <= y2.

The input ends with a line of single zero.

Output
For each test case, output a single line with the total area of window covered by posters.

Sample Input
2
0 0 10 10 1 1 9 9
2 2 8 8 3 3 7 7
0

Sample Output
56

原文地址:https://www.cnblogs.com/wutongtong3117/p/7673325.html