Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Language: Holey Cloth
Description 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.
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 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). Output The output 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 Source Northeastern Europe 2001, Far-Eastern Subregion |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator