Problems > The Largest Lake

The Largest Lake

Difficulty: 1400 4000 ms 128 MB

bfs graphs

Same map — print the area (cell count) of the largest lake, or 0 if there is no water.

Input: the first line has N and M; the next N lines each have M characters (L/W).

Output: the largest lake's area.

Constraints:

  • 1 ≤ N, M ≤ 500

Sample Tests

Input 1
3 4
LWWL
LLWL
WLLL
Output 1
3
Input 2
2 2
LL
LL
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.