http://acm.hdu.edu.cn/showproblem.php?pid=3265
Posters
Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5762 Accepted Submission(s): 1363
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
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
Source
2009 Asia Ningbo Regional Contest Hosted by NIT
#include
#include
#include
#include
#include