1061: Floor Fill 1
[Creator : ]
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.
For example:
8 8 <--- 8 rows and 8 columns
XXXOOOOO
XXXXXOOX
XXXXXXXX
XXOOOXXX
XXXXXOOO
XXXOOOOO
XOOOOOOO
XXXXXXXX
then you should output 15 , the area for one grid is 1.
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.
For example:
8 8 <--- 8 rows and 8 columns
XXXOOOOO
XXXXXOOX
XXXXXXXX
XXOOOXXX
XXXXXOOO
XXXOOOOO
XOOOOOOO
XXXXXXXX
then you should output 15 , the area for one grid is 1.
Input
The first line contains two integers M and N
In the next M rows , each row contains N characters of X or O
In the next M rows , each row contains N characters of X or O
Output
One integer which is the largest area with 'O's
Sample Input Copy
8 8
XXXOOOOO
XXXXXOOX
XXXXXXXX
XXOOOXXX
XXXXXOOO
XXXOOOOO
XOOOOOOO
XXXXXXXX
Sample Output Copy
15