编程介的小学生 2017-04-27 06:26 采纳率: 20.5%
浏览 754
已采纳

Holey Cloth

Several pieces of cloth are laid out on the table without overlapping each other. These pieces contain many holes, some so big that entire other piece of cloth may fit into them. Digital black-and-white image of the tabletop was taken, on which areas covered by cloth are represented with '*'s and not covered areas with '.'s. A single piece of cloth is thus represented with 4-connected area of '*'s - i.e., a group of '.'s located next to each other horizontally or vertically, but not diagonally.

.***..***
.*.*.**.*
.***.*.**
...*.*.

For example, on the image on the left there are three pieces - one without holes, and two with one hole each - first has area of 8, and the second - area of 12.

Your goal is to find the piece with the most holes in it. The hole is a 4-connected area of '.'s completely surrounded with '*'s. If several pieces have the same number of holes, you must select the one with the smallest area.

Input

In the first line of input file there are two numbers W and H (1 <= W <= 100, 1 <= H <= 100), separated by spaces. Next H lines contain W characters each. Characters in these lines are either '*' (ASCII 42) or '.' (ASCII 46).

Process to the end of file.

Output

The output file must contain a single integer - the area of the smallest of most holey pieces. If there are no pieces with the holes, the output file must contain zero.

Sample Input

9 5
.********
.*......*
.*..**..*
.*......*
.********

Sample Output

22

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-11 15:56
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢