比赛 暑假培训B班二测 评测结果 AAAAAAEA
题目名称 劣质的草 最终得分 87
用户昵称 bingo 运行时间 0.149 s
代码语言 Pascal 内存使用 4.95 MiB
提交时间 2012-07-22 11:24:17
显示代码纯文本
const
 s:array[1..8,1..2]of integer=((0,-1),(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1));
var
 a:array[0..1001,0..1001]of longint;
 b:array[0..1001,0..1001]of boolean;
 r,c,i,j,k,t:longint;
procedure can(y,x:integer);
 var
  i,j:integer;
 begin
  b[y,x]:=false;
  for i:=1 to 8 do
   if b[y+s[i,1],x+s[i,2]] then can(y+s[i,1],x+s[i,2]);
 end;
begin
 assign(input,'badgras.in');
 assign(output,'badgras.out');
 reset(input);
 rewrite(output);
 readln(r,c);
 for i:=1 to r do
  for j:=1 to c do
   begin
    read(a[i,j]);
    if a[i,j]<>0 then b[i,j]:=true;
   end;
 for i:=1 to r do
  for j:=1 to c do
   if b[i,j] then begin t:=t+1;can(i,j);end;
 writeln(t);
 close(input);
 close(output);
end.