当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5925:Coconuts

题目描述
TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams about eating. One day, TanBig dreams of a field of coconuts, and the field looks like a large chessboard which has R rows and C columns. In every cell of the field, there is one coconut. Unfortunately, some of the coconuts have gone bad. For sake of his health, TanBig will eat the coconuts following the rule that he can only eat good coconuts and can only eat a connected component of good coconuts one time(you can consider the bad coconuts as barriers, and the good coconuts are 4-connected, which means one coconut in cell (x, y) is connected to (x - 1, y), (x + 1, y), (x, y + 1), (x, y - 1).

Now TanBig wants to know how many times he needs to eat all the good coconuts in the field, and how many coconuts he would eat each time(the area of each 4-connected component).
输入解释
The first line contains apositiveinteger T($T \leq 10$) which denotes the test cases. T test cases begin from the second line. In every test case, the first line contains two integers R and C, $0 < R,C \leq 10^9$ the second line contains an integer n, the number of bad coconuts, $0\leq n \leq 200$ from the third line, there comes n lines, each line contains two integers, $x_i$ and $y_i$, which means in cell($x_i, y_i$), there is a bad coconut.

It is guaranteed that in the input data, the first row and the last row will not have bad coconuts at the same time, the first column and the last column will not have bad coconuts at the same time.
输出解释
For each test case, output "Case #x:" in the first line, where x denotes the number of test case, one integer k in the second line, denoting the number of times TanBig needs, in the third line, k integers denoting the number of coconuts he would eat each time, you should output them in increasing order.
输入样例
2

3 3
2
1 2
2 1

3 3
1
2 2
输出样例
Case #1:
2
1 6
Case #2:
1
8
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5925

最后修改于 2020-10-25T23:26:46+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
9000/4500MS(Java/Others) 65536/65536K(Java/Others)