

PictureTime Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9508 Accepted Submission(s): 4115 Problem Description A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered by the others. The length of the boundary of the union of all rectangles is called the perimeter. Write a program to calculate the perimeter. An example with 7 rectangles is shown in Figure 1. The corresponding boundary is the whole set of line segments drawn in Figure 2. The vertices of all rectangles have integer coordinates. Input Your program is to read from standard input. The first line contains the number of rectangles pasted on the wall. In each of the subsequent lines, one can find the integer coordinates of the lower left vertex and the upper right vertex of each rectangle. The values of those coordinates are given as ordered pairs consisting of an xcoordinate followed by a ycoordinate. 0 <= number of rectangles < 5000 All coordinates are in the range [10000,10000] and any existing rectangle has a positive area. Please process to the end of file. Output Your program is to write to standard output. The output must contain a single line with a nonnegative integer which corresponds to the perimeter for the input rectangles. Sample Input
Sample Output
Source  
