记录编号 4074 评测结果 AAAAAAAAAA
题目名称 [USACO Nov07] 最大的湖 最终得分 100
用户昵称 Gravatar苏轼 是否通过 通过
代码语言 Pascal 运行时间 0.010 s
提交时间 2008-10-13 19:05:06 内存使用 0.32 MiB
显示代码纯文本
  1. program cch(input,output);
  2. const
  3. xx:array[1..4] of integer=(-1,0,1,0);
  4. yy:array[1..4] of integer=(0,1,0,-1);
  5. var
  6. i,j,k,m,n,tot,max,x,y:integer;
  7. a:array[1..100,1..100] of boolean;
  8. ans:array[1..100000] of integer;
  9.  
  10. procedure floodfill(x,y:integer);
  11. var
  12. i,x1,y1:integer;
  13. begin
  14. inc(ans[tot]);
  15. a[x,y]:=false;
  16. for i:=1 to 4 do
  17. begin
  18. x1:=x+xx[i]; y1:=y+yy[i];
  19. if (x1>=1)and(x1<=n)and(y1>=1)and(y1<=m) then
  20. if a[x1,y1] then
  21. floodfill(x1,y1);
  22. end;
  23. end;
  24.  
  25. begin
  26. assign(input,'lake.in');
  27. assign(output,'lake.out');
  28. reset(input);
  29. rewrite(output);
  30. readln(n,m,k);
  31. for i:=1 to n do
  32. for j:=1 to m do
  33. a[i,j]:=false;
  34. for i:=1 to k do
  35. begin
  36. readln(x,y);
  37. a[x,y]:=true;
  38. end;
  39. tot:=0;
  40. for i:=1 to n do
  41. for j:=1 to m do
  42. if a[i,j] then
  43. begin
  44. inc(tot);
  45. ans[tot]:=0;
  46. floodfill(i,j);
  47. end;
  48. max:=0;
  49. for i:=1 to tot do
  50. if ans[i]>max then max:=ans[i];
  51. write(max);
  52. close(input);
  53. close(output);
  54. end.