Time limit
2s
Memory limit
128 MB
On the eighth floor of Koresco Condominium, food waste has been dropped along a hallway. Food cells adjacent vertically or horizontally belong to the same connected lump.
A teacher wants to avoid at least the largest lump while walking through the hallway. Given the coordinates of the food cells, find the size of the largest lump.
The first line contains the hallway height N (1 ≤ N ≤ 100), width M (1 ≤ M ≤ 100), and the number of food cells K (1 ≤ K ≤ N×M). Each of the next K lines contains the coordinate (r, c) of one food cell.
The row r is counted from the top, and the column c is counted from the left. No coordinate is given more than once.
Print the size of the largest group of food cells connected vertically or horizontally.
# . . .. # # .# # . .In the layout above, four food cells are connected vertically or horizontally, so the largest lump has size 4. Cells touching only diagonally are not connected.
# . . .. # # .# # . .