All submissions for this problem are available.
It is the rainy season, and puddles of various sizes have formed in
the NITD campus. After the freshers party, the students have been
longing for another party with a swimming pool. With the puddles
forming, they decide to have their party in the largest puddle they
can find. You will be given the map of the campus as a matrix. A .
Each cell can have three characters, a dot character ‘.’ specifying
grass, ‘w’ specifying water, and ‘b’ specifying building (all without
quotes). You have to find the size of the largest puddle. A puddle is
formed by water cells, and all cells are connected to there
respective cells to the top, right, bottom and left.
The first line of input will be an integer T, denoting the number of
test cases. The first line of each test case will have two integers N
and M denoting the size of the campus. The next N lines will have
M characters each (not separated by a space) which will be one of
‘.’, ‘w’ or ‘b’ (without the quotes).
For each text case, in a single line by itself, print the size of the
- 1 <= T <= 10
- 1 <= N, M <= 10^3
Input: 1 4 4 w… .www .wbw .www Output: 8
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA|
Fetching successful submissions
If you are still having problems, see a sample solution here.