const SIZE = 100; var n, m, p, count, ans, x, y, i, j : integer; a : array[1..SIZE, 1..SIZE] of integer; procedure colour(x, y : integer); begin inc(count); a[x][y] := 1; if (x > 1) and (a[x - 1][y] = 0) then colour(x - 1, y); if (y > 1) and (a[x][y - 1] = 0) then colour(x, y - 1); if (x < n) and (a[x + 1][y] = 0) then colour(x + 1, y); if (y < m) and (a[x][y + 1] = 0) then colour(x, y + 1); end; begin fillchar(a, sizeof(a), 0); readln(n, m, p); for i := 1 to p do begin read(x, y); a[x][y] := 1; end; ans := 0; for i := 1 to n do for j := 1 to m do if a[i][j] = 0 then begin count := 0; colour(i, j); if (ans < count) then ans := count; end; writeln(ans); end.
输入:
6 5 9
1 4
2 3
2 4
3 2
4 1
4 3
4 5
5 4
6 4
输出:1