Problem1062--Floor Fill 2

1062: Floor Fill 2

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description

Given a m*n grids, each grid with character x or o,
if the grid is connected to the grid of its left, right, up or down
with the same character, those grids are in the same area.
we would like to know what is the largest area in the grid with o's;
but this time, the area of 'O' must connect to the edge of the grid.

For example:
7 9    <--- 7 rows and 9 columns
XXXOOOOOX
XXXXXOOXX
XXXXXXXXX
XXOOOXXXX
XXXXXOOOX
XOOOOOOOX
XXXXXXXXX

then you should output 7 , (the area with 15 'O' is not connected to the edge); the area for one grid is 1.

Sample Input Copy

7 9
XXXOOOOOX
XXXXXOOXX
XXXXXXXXX
XXOOOXXXX
XXXXXOOOX
XOOOOOOOX
XXXXXXXXX

Sample Output Copy

7

Source/Category