A7961 | Chocolate
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
输入格式
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.
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.
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+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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted