描述
Farmer John's farm was flooded in the most recent storm, a fact only aggravated by the information that his cows are deathly afraid of water. His insurance agency will only repay him, however, an amount depending on the size of the largest "lake" on his farm.
The farm is represented as a rectangular grid with N (1 <= N <= 100) rows and M (1 <= M <= 100) columns. Each cell in the grid is either dry or submerged, and exactly K (1 <= K <= N*M) of the cells are submerged. As one would expect, a lake has a central cell to which other cells connect by sharing a long edge (not a corner). Any cell that shares a long edge with the central cell or shares a long edge with any connected cell becomes a connected cell and is part of the lake.
输入
* Line 1: Three space-separated integers: N, M, and K
* Lines 2..K+1: Line i+1 describes one submerged location with two space separated integers that are its row and column: R and C
输出
* Line 1: The number of cells that the largest lake contains.
OpenJudge - 2405:Avoid The Lakes
翻译
描述
农场主约翰的农场在最近的暴风雨中被淹没了,而他的牛非常怕水,这更加剧了这一情况。不过,他的保险公司只会根据他农场最大“湖”的大小偿还他的保险金额。
场表示为一个矩形网格,有N (1 <= N <= 100)行和M (1 <= M <= 100)列。网格中的每个单元要么是干燥的,要么是淹没的,K (1 <= K <= N*M)个单元被淹没。正如人们所预料的那样,湖泊有一个中央部分,其他部分通过共享一个长边(而不是一个角)与之连接。任何与中央部分共享长边的部分或与任何连接的部分共享长边的部分都成为连接的部分,成为湖的一部分。
输入
第一行:三个整数:M,N,K
第二行开始的K+1行:第i+1行描述了一个淹没位置,用两个用空格分隔的整数表示它的行和列:R和C
输出
最大的湖所拥有的部分数量