HSBCOA #3
Find Largest House Area
估计中等可在线判题
考点(AI 标注)网格搜索
In the grid, 1 represents a roof and 0 represents open ground. Only 1s adjacent up, down, left or right belong to the same house; diagonal cells are not connected. Find the number of cells covered by the largest house.
The original problem's connectivity rule is clear; this site adds the grid size and the result for a grid with no houses.
输入格式
The first line contains n m (1≤n,m, and nm≤200000); each of the next n lines contains m values, each 0 or 1.
输出格式
Output the area of the largest connected component; output 0 if there is no 1.
样例 1
输入:
4 3
0 0 0
0 1 1
0 0 0
1 1 0
输出:
2
样例 2
输入:
2 2
1 0
0 1
输出:
1
样例 3
输入:
1 1
0
输出:
0