#C1923. Largest Connected X Region
Largest Connected X Region
Largest Connected X Region
You are given a grid of characters, where each cell is either 'X' or 'O'. Your task is to determine the size of the largest connected region of cells marked 'X'. Two cells are connected if they are adjacent horizontally or vertically.
Note: Regions are only connected in the four cardinal directions (up, down, left, right).
Example:
For the grid:
XOXOX OXOXO XXXXX OXOXOThe largest connected region of 'X' has size 9.
inputFormat
The input begins with an integer T denoting the number of test cases. For each test case, the first line contains two integers M and N, separated by a space, representing the number of rows and columns of the grid respectively. This is followed by M lines, each containing a string of length N consisting only of the characters 'X' and 'O'.
outputFormat
For each test case, output a single line containing the size of the largest connected region of cells that are marked 'X'.## sample
2
4 5
XOXOX
OXOXO
XXXXX
OXOXO
3 3
XOX
OXX
XOO
9
3
</p>