巧克力AI (CI翻译)
Bob has a rectangular chocolate bar of the size $*W* × *H*$. He introduced a cartesian coordinate system so that the point $(0, 0)$ corresponds to the lower-left corner of the bar, and the point $(*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* = *x*_{*c*}$ or $*y* = *y*_{*c*}$, where $*x*_{*c*}$ and $*y*_{*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 $*n*$ breaks and wrote them down in his notebook in arbitrary order. At the end he got $*n* + 1$ parts. Now he wants to calculate their areas. Bob is lazy, so he asks you to do this task.
Bob 有一块大小为 $*W* × *H*$ 的矩形巧克力。他建立了笛卡尔坐标系,使点 $(0, 0)$ 对应巧克力的左下角,点 $(*W*, *H*)$ 对应巧克力的右上角。Bob 决定通过掰开巧克力将其分成若干块。每次掰开都是一条平行于某个坐标轴、连接巧克力边界的线段。更正式地说,每次掰开沿直线 $*x* = *x*_{*c*}$ 或 $*y* = *y*_{*c*}$ 进行,其中 $*x*_{*c*}$ 和 $*y*_{*c*}$ 是整数。一次掰开应当将巧克力的一块分成两块非空部分。在 Bob 将某一块分成两块后,他会将得到的两块分别且相互独立地继续掰开。此外,他不会移动巧克力的各个部分。Bob 一共进行了 $*n*$ 次掰开,并以任意顺序将它们记录在笔记本中。最终,他得到了 $*n* + 1$ 块巧克力。现在他想计算这些巧克力块的面积。Bob 很懒,所以请你完成这个任务。AI (CI翻译)
Input
输入格式
AI (CI翻译)The first line contains 3 integers $*W*$, $*H*$ and $*n*$ ($1 ≤ *W*, *H*, *n* ≤ 100$) — width of the bar, height of the bar and amount of breaks. Each of the following $*n*$ lines contains four integers $*x*_{*i*, 1}, *y*_{*i*, 1}, *x*_{*i*, 2}, *y*_{*i*, 2}$ — coordinates of the endpoints of the $*i*$-th break ($0 ≤ *x*_{*i*, 1} ≤ *x*_{*i*, 2} ≤ *W*, 0 ≤ *y*_{*i*, 1} ≤ *y*_{*i*, 2} ≤ *H*$, or $*x*_{*i*, 1} = *x*_{*i*, 2}$, or $*y*_{*i*, 1} = *y*_{*i*, 2}$). Breaks are given in arbitrary order.
第一行包含 3 个整数 $*W*$、$*H*$ 和 $*n*$($1 ≤ *W*, *H*, *n* ≤ 100$),分别表示巧克力的宽度、高度以及掰开的次数。接下来的 $*n*$ 行中,每行包含 4 个整数 $*x*_{*i*, 1}, *y*_{*i*, 1}, *x*_{*i*, 2}, *y*_{*i*, 2}$,表示第 $*i*$ 次掰开的两个端点的坐标($0 ≤ *x*_{*i*, 1} ≤ *x*_{*i*, 2} ≤ *W*, 0 ≤ *y*_{*i*, 1} ≤ *y*_{*i*, 2} ≤ *H*$,或者 $*x*_{*i*, 1} = *x*_{*i*, 2}$,或者 $*y*_{*i*, 1} = *y*_{*i*, 2}$)。掰开的记录顺序是任意的。AI (CI翻译)
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.
保证给出的掰开集合是正确的,即存在一种给定掰开的排列顺序,使得每次掰开都恰好将巧克力的一块分成两块非空部分。AI (CI翻译)
Output
输出格式
AI (CI翻译)Output $*n* + 1$ numbers — areas of the resulting parts in the increasing order.
按递增顺序输出 $*n* + 1$ 个数,表示最终各块巧克力的面积。AI (CI翻译)
样例
2 2 2
1 0 1 2
0 1 1 1
1 1 2
2 2 3
1 0 1 2
0 1 1 1
1 1 2 1
1 1 1 1
2 4 2
0 1 2 1
0 3 2 3
2 2 4
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。