
ZOJ Problem Set  1752
Starting with an initial colorless background, we will paint a sequence of potentially overlapping, horizontallyaligned rectangles of various colors. The problem is to determine the exposed area of a given color.
Each of the next n lines of the dataset contains information about a rectangle, and the lines are given in order of the painting sequence. The first number on the line is an integer 0 < c' < 8, representing the rectangle's color. The next two integer values on the line are respectively the x and ycoordinates of any corner of the rectangle. The last two integer values are respectively the x and ycoordinates of the diagonally opposite corner of the rectangle. All coordinates lie in the range from 100 to +100 inclusively. The end of input will be indicated by a dataset with n = 0. This dataset should not be processed.
Source: Southeast USA 2000 