#K9061. Largest Island Area
Largest Island Area
Largest Island Area
You are given a grid of size \(n \times m\) representing a village. Each cell of the grid is either land ('L') or water ('W'). An island is defined as a group of horizontally or vertically connected land cells. Your task is to compute the area (i.e., the number of cells) of the largest island in the grid.
Note: Two land cells are considered connected if they share a common edge. Diagonally adjacent cells are not connected.
For example, for the grid below:
L W L W L L L L L W W L W W W W W L L L
The largest island has an area of 7 cells.
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains two integers \(n\) and \(m\) separated by a space, denoting the number of rows and columns.
- The next \(n\) lines each contain a string of length \(m\) consisting of characters 'L' and 'W', representing the grid.
outputFormat
Output via standard output (stdout) a single integer: the area of the largest island in the grid.
## sample4 5
LWLWL
LLLLW
WLWWW
WWLLL
7
</p>