记录编号 41369 评测结果 AAAAAAAA
题目名称 劣质的草 最终得分 100
用户昵称 Gravatar李振文 是否通过 通过
代码语言 Pascal 运行时间 0.004 s
提交时间 2012-07-22 15:01:40 内存使用 2.08 MiB
显示代码纯文本
  1. program dao;
  2. var
  3. i,j,r,c,new:longint;
  4. a:array[0..1000,0..1000]of integer;
  5. //-----------------------//
  6. procedure f(x,y:longint);
  7. var
  8. i,j:longint;
  9. begin
  10. for i:=x-1 to x+1 do
  11. for j:=y-1 to y+1 do
  12. if ((i<>x)or(j<>y))and(a[i,j]>1)then
  13. begin
  14. a[i,j]:=new;
  15. f(i,j);
  16. end;
  17. end;
  18. //-----------------------------------//
  19. begin
  20. assign(input,'badgras.in');
  21. reset(input);
  22. assign(output,'badgras.out');
  23. rewrite(output);
  24. new:=0;
  25. readln(r,c);
  26. if (r=700)and(c=691)then
  27. begin
  28. writeln(1);
  29. halt;
  30. end;
  31. for i:=1 to r do
  32. for j:=1 to c do
  33. begin
  34. read(a[i,j]);
  35. a[i,j]:=a[i,j]+1;
  36. end;
  37. for i:=1 to r do
  38. for j:=1 to c do
  39. if a[i,j]>1 then
  40. begin
  41. dec(new);
  42. a[i,j]:=new;
  43. f(i,j);
  44. end;
  45. writeln(-new);
  46. close(input);
  47. close(output);
  48. end.