{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"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.\r\u003cbr\u003e\r\u003cbr\u003eWrite a program to calculate the perimeter. An example with 7 rectangles is shown in Figure 1.\r\u003cbr\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/20d57b877fcc7082d971e6e66ada3cfa?v\u003d1713883763\"\u003e\u003c/center\u003e\r\u003cbr\u003eThe corresponding boundary is the whole set of line segments drawn in Figure 2.\r\u003cbr\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/9b7f8dfac2af36a4a557c087c5f55e0e?v\u003d1713883763\"\u003e\u003c/center\u003e\r\u003cbr\u003eThe vertices of all rectangles have integer coordinates.\r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"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 x-coordinate followed by a y-coordinate.\r\u003cbr\u003e\r\u003cbr\u003e0 \u0026lt;\u003d number of rectangles \u0026lt; 5000\r\u003cbr\u003eAll coordinates are in the range [-10000,10000] and any existing rectangle has a positive area."}},{"title":"Output","value":{"format":"HTML","content":"Your program is to write to standard output. The output must contain a single line with a non-negative integer which corresponds to the perimeter for the input rectangles."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7\r\n-15 0 5 10\r\n-5 8 20 25\r\n15 -4 24 14\r\n0 -6 16 4\r\n2 15 10 22\r\n30 10 36 20\r\n34 0 40 16\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e228\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}