程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> storm-Avoid The Lakes

storm-Avoid The Lakes

編輯:編程解疑
Avoid The Lakes

Description
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.

Input

  • 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

Output

  • Line 1: The number of cells that the largest lake contains. 

Sample Input
3 4 5
3 2
2 2
3 1
2 3
1 1
Sample Output
4

最佳回答:


http://www.xuebuyuan.com/552900.html

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved