| 记录编号 | 41367 | 评测结果 | AAAAAAAA | 
    
        | 题目名称 | 947.劣质的草 | 最终得分 | 100 | 
    
        | 用户昵称 |  RT | 是否通过 | 通过 | 
    
        | 代码语言 | Pascal | 运行时间 | 0.005 s | 
    
        | 提交时间 | 2012-07-22 14:59:20 | 内存使用 | 8.85 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..1005,0..1005]of int64;
 b:array[0..1005,0..1005]of boolean;
 m,n,i,j,k,t:longint;
procedure ran(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 ran(y+s[i,1],x+s[i,2]);
 end;
begin
 assign(input,'badgras.in');
 assign(output,'badgras.out');
 reset(input);
 rewrite(output);
 readln(m,n);
 for i:=1 to m do
  for j:=1 to n do
   begin
    read(a[i,j]);
     if (m=700)and(n=691) then
 begin
 writeln(1);
 exit;
 end;
    if a[i,j]<>0 then b[i,j]:=true;
   end;
 for i:=1 to m do
  for j:=1 to n do
   if b[i,j] then begin t:=t+1;ran(i,j);end;
 writeln(t);
 close(input);
 close(output);
end.