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

建议使用的浏览器:

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

2808:Islands

题目描述
There are so many islands in the sea. Some islands are enclosed by other ones. So, we can classify all the islands to several levels. An island has a level of 0 if it is contains no other islands. An island has a level of K+1 if it contains one or more islands and the highest level of the contained island(s) is K. Now, the map of the sea is given. Your task is to calculate the areas of islands in each level.
输入解释
The input contains several test cases. Each test case starts with a line contains two numbers N and M(1<=N<=100,1<=M<=100) which indicate the size of the map. The next N lines will contain M characters each to represent the map. Each character is either 'x' or '.'. A sea is defined as a maximal connected group of '.' cells, where two '.' cells are connected if they are vertically or horizontally adjacent. An island is defined as a maximal connected group of 'x' cells, where two 'x' cells are connected if they are vertically, horizontally, or diagonally adjacent. An island A contains island B if A and B are different and if you start sailing from any point of island B, you won't be able to sail out of island A.
输出解释
For each test case, output a single line with K+1 integers, where K is the highest level of an island in the map. The i-th number in the line is the total area of islands of level (i-1).
输入样例
1 1
x
5 7
.xxxxx.
x.....x
x.x.x.x
x.....x
.xxxxx.
输出样例
1
2 16
来自杭电HDUOJ的附加信息
Recommend lcy

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

源链接: HDU-2808

最后修改于 2020-10-25T22:57:02+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)