10088_RectangleCutting

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

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

Pro.ID

10088

Title

Rectangle Cutting

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    In the small historical village of Basinia, there is a popular activity in wedding ceremonies called rectangle cutting. During this activity, each close relative of the bride comes and cuts a rectangle in the wedding cake (but does not take a piece). The cake has a rectangular shape. The problem is to count how many pieces are in the cake after rectangle-cutting.

    For example, in the following figure, the cake size is 3 × 5, and three people have made rectangular cuts in it. As a result, the cake is cut into six pieces.

    Each rectangular cut is specified by the (x, y) coordinates of its two opposite corners. The input for the above figure can be found in the first sample input. As there are large families in Basinia, the number of pieces may be large and we need a computer program to compute it.

    输入

    The input contains several test cases. Each test has several lines. The first line has two integers w (1 ≤ w ≤ 20) and h (1 ≤ h ≤ 20) which are the width and height of the cake. The second line contains a single integer n (0 ≤ n ≤ 50) which is the number of people who cut rectangles in the cake. After this, there are n lines each containing the integers x1, y1, x2, y2 which are the coordinates of two opposite corners of the cut. You may assume 0 ≤ x1, x2w and 0 ≤ y1, y2h. The last line of the input is a line containing two zeros.

    输出

    Description

    In the small historical village of Basinia, there is a popular activity in wedding ceremonies called rectangle cutting. During this activity, each close relative of the bride comes and cuts a rectangle in the wedding cake (but does not take a piece). The cake has a rectangular shape. The problem is to count how many pieces are in the cake after rectangle-cutting.

    For example, in the following figure, the cake size is 3 × 5, and three people have made rectangular cuts in it. As a result, the cake is cut into six pieces.

    Each rectangular cut is specified by the (x, y) coordinates of its two opposite corners. The input for the above figure can be found in the first sample input. As there are large families in Basinia, the number of pieces may be large and we need a computer program to compute it.

    Input

    The input contains several test cases. Each test has several lines. The first line has two integers w (1 ≤ w ≤ 20) and h (1 ≤ h ≤ 20) which are the width and height of the cake. The second line contains a single integer n (0 ≤ n ≤ 50) which is the number of people who cut rectangles in the cake. After this, there are n lines each containing the integers x1, y1, x2, y2 which are the coordinates of two opposite corners of the cut. You may assume 0 ≤ x1, x2w and 0 ≤ y1, y2h. The last line of the input is a line containing two zeros.

    Output

    For each test case, write the number of pieces the cake is cut into.

    Sample Input
    3 5
    3
    1 1 3 2
    4 0 2 3
    4 0 5 1
    6 6
    2
    2 0 5 3
    3 1 4 2
    0 0
    Sample Output
    6
    3
    Source

    样例输入

    3 5
    3
    1 1 3 2
    4 0 2 3
    4 0 5 1
    6 6
    2
    2 0 5 3
    3 1 4 2
    0 0

    样例输出

    6
    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部