记录编号 |
41398 |
评测结果 |
AAAAAAAA |
题目名称 |
劣质的草 |
最终得分 |
100 |
用户昵称 |
英雄寞乌云然 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.054 s |
提交时间 |
2012-07-22 16:05:08 |
内存使用 |
3.03 MiB |
显示代码纯文本
program fl;
var
r:array[0..1000,0..1000] of integer;
z:array[0..1000,0..1000] of shortint;
a,b,c,d,m,n,pd:integer; ys:longint;
procedure color(x,y:integer);
begin
if (x<>0) and (x<(m+1)) then
if (y<>0) and (y<(n+1)) then
if z[x,y]=0 then
begin
z[x,y]:=1;
if (r[x-1,y]<>0) and (z[x-1,y]<>1)then color(x-1,y);
if (r[x-1,y+1]<>0) and (z[x-1,y+1]<>1)then color(x-1,y+1);
if (r[x,y+1]<>0) and (z[x,y+1]<>1)then color(x,y+1);
if (r[x+1,y+1]<>0) and (z[x+1,y+1]<>1)then color(x+1,y+1);
if (r[x+1,y]<>0) and (z[x+1,y]<>1)then color(x+1,y);
if (r[x+1,y-1]<>0) and (z[x+1,y-1]<>1)then color(x+1,y-1);
if (r[x,y-1]<>0) and (z[x,y-1]<>1)then color(x,y-1);
if (r[x-1,y-1]<>0) and (z[x-1,y-1]<>1)then color(x-1,y-1);
end;
end;
begin
assign(input,'badgras.in');
reset(input);
assign(output,'badgras.out');
rewrite(output);
read(n,m);
for a:=1 to n do
for b:=1 to m do
begin read(d); r[b,a]:=d;if d=0 then pd:=1; end;
{=================================================}
ys:=0;
if pd<>1 then write(1)
else begin
for a:=1 to n do
for b:=1 to m do
if r[b,a]<>0 then
if z[b,a]<>1 then
begin
ys:=ys+1;
color(b,a);
end;
write(ys); end;
{=================================================}
close(input);
close(output);
end.