10210_Picture

2022-5-16 18:16| 发布者: Hocassian| 查看: 86| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504662983900-Problem List-采集的数据-后羿采集器.html

Pro.ID

10210

Title

Picture

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10210

AC

13

Submit

46

Ratio

28.26%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    A number, N ( 1 ≤ N < 5000 ), 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.

    Figure 1 shows an example with seven rectangles:


    Figure 1. A set of seven rectangles

    The corresponding boundary is the whole set of line segments drawn in Figure 2:


    Figure 2. The boundary of the set of rectangles

    The vertices of all rectangles have integer coordinates. All coordinates are in the range [-10000, 10000] and any existing rectangle has a positive area. The numeric value of the result fits in a 32-bit signed representation.

    输入

    Multiple test cases. For each case,

    Line 1:   N, the number of rectangles pasted on the wall.

    Lines 2..N+1:   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.

    输出

    Description

    A number, N ( 1 ≤ N < 5000 ), 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.

    Figure 1 shows an example with seven rectangles:


    Figure 1. A set of seven rectangles

    The corresponding boundary is the whole set of line segments drawn in Figure 2:


    Figure 2. The boundary of the set of rectangles

    The vertices of all rectangles have integer coordinates. All coordinates are in the range [-10000, 10000] and any existing rectangle has a positive area. The numeric value of the result fits in a 32-bit signed representation.

    Input

    Multiple test cases. For each case,

    Line 1:   N, the number of rectangles pasted on the wall.

    Lines 2..N+1:   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.

    Output

    For each case, output a single line with a non-negative integer which corresponds to the perimeter for the input rectangles.

    Sample Input

    7
    -15 0 5 10
    -5 8 20 25
    15 -4 24 14
    0 -6 16 4
    2 15 10 22
    30 10 36 20
    34 0 40 16

    Sample Output

    228

    Source

    样例输入

    7
    -15 0 5 10
    -5 8 20 25
    15 -4 24 14
    0 -6 16 4
    2 15 10 22
    30 10 36 20
    34 0 40 16

    样例输出

    228

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部