z-musicians
The famous POP-Rock-Metal-Pascal bend “FORMAT C:”, want to organize a concert on a field so that the concert is in the largest connected area (meaning it they can have maximum number of guests). We represent the field by M by N square tiles, where each time is either empty or has a fence, also, the field is surrounded by fences. The connected area is an area in which you can get from any tile to any other tile by moving left, right, up or down (along empty tiles).
Your task is to find the size of the largest connected area on the given field
InputThe first line contains two numbers N and M, representing the dimensions of the field (1 <= N,M <= 1000). Each of the next N lines contains M characters ‘.’ (dot) or ‘#’ . We have '.' representing an empty tile, and '#' a tile with a fence on it.
OutputTo the standard output write one integer that represents the size (in fields) of the biggest connected area on the field.
Input:
Output:
10 20
.....#..............
.....#..............
.....#..............
.....#..............
######..............
.......###..........
.......#.#..........
.......###...#######
.............#.....#
.............#######
Output:
140Input:
Output:
15 15
.......#.......
......#.#......
.....#...#.....
....#.....#....
...#.......#...
..#.........#..
.#...#####...#.
#....#...#....#
.#...#####...#.
..#.........#..
...#.......#...
....#.....#....
.....#...#.....
......#.#......
.......#.......
Output:
70Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.