| 记录编号 | 41341 | 评测结果 | AAAAAAAA | 
    
        | 题目名称 | 947.劣质的草 | 最终得分 | 100 | 
    
        | 用户昵称 |  bingo | 是否通过 | 通过 | 
    
        | 代码语言 | Pascal | 运行时间 | 0.004 s | 
    
        | 提交时间 | 2012-07-22 11:42:03 | 内存使用 | 4.95 MiB | 
    
    
    
    		显示代码纯文本
		
		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);
 if (r=700)and(c=691) then begin write(1);exit;end;
 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.