CF31D.Chocolate

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Bob has a rectangular chocolate bar of the size W×HW×H . He introduced a cartesian coordinate system so that the point (0,0)(0,0) corresponds to the lower-left corner of the bar, and the point (W,H)(W,H) corresponds to the upper-right corner. Bob decided to split the bar into pieces by breaking it. Each break is a segment parallel to one of the coordinate axes, which connects the edges of the bar. More formally, each break goes along the line x=xcx=x_{c} or y=ycy=y_{c} , where xcx_{c} and ycy_{c} are integers. It should divide one part of the bar into two non-empty parts. After Bob breaks some part into two parts, he breaks the resulting parts separately and independently from each other. Also he doesn't move the parts of the bar. Bob made nn breaks and wrote them down in his notebook in arbitrary order. At the end he got n+1n+1 parts. Now he wants to calculate their areas. Bob is lazy, so he asks you to do this task.

输入格式

The first line contains 3 integers WW , HH and nn ( 1<=W,H,n<=1001<=W,H,n<=100 ) — width of the bar, height of the bar and amount of breaks. Each of the following nn lines contains four integers xi,1,yi,1,xi,2,yi,2x_{i,1},y_{i,1},x_{i,2},y_{i,2} — coordinates of the endpoints of the ii -th break ( 0<=xi,1<=xi,2<=W,0<=yi,1<=yi,2<=H0<=x_{i,1}<=x_{i,2}<=W,0<=y_{i,1}<=y_{i,2}<=H , or xi,1=xi,2x_{i,1}=x_{i,2} , or yi,1=yi,2y_{i,1}=y_{i,2} ). Breaks are given in arbitrary order.

It is guaranteed that the set of breaks is correct, i.e. there is some order of the given breaks that each next break divides exactly one part of the bar into two non-empty parts.

输出格式

Output n+1n+1 numbers — areas of the resulting parts in the increasing order.

输入输出样例

  • 输入#1

    2 2 2
    1 0 1 2
    0 1 1 1
    

    输出#1

    1 1 2 
  • 输入#2

    2 2 3
    1 0 1 2
    0 1 1 1
    1 1 2 1
    

    输出#2

    1 1 1 1 
  • 输入#3

    2 4 2
    0 1 2 1
    0 3 2 3
    

    输出#3

    2 2 4 
首页