比赛 |
暑假培训B班二测 |
评测结果 |
MMMMMMMM |
题目名称 |
劣质的草 |
最终得分 |
0 |
用户昵称 |
英雄寞乌云然 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2012-07-22 11:16:34 |
显示代码纯文本
program fl;
var
r,z:array[0..10000,0..10000] of longint;
t:array[1..9999] of integer;
a,b,c,d,m,n,ys,zd,fx,x,y,mj,yb,yl,u:longint;
procedure color(x,y,w:longint);
var h,i,j,k,ls:longint;
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,w);
if (r[x-1,y+1]<>0) and (z[x-1,y+1]<>1)then color(x-1,y+1,w);
if (r[x,y+1]<>0) and (z[x,y+1]<>1)then color(x,y+1,w);
if (r[x+1,y+1]<>0) and (z[x+1,y+1]<>1)then color(x+1,y+1,w);
if (r[x+1,y]<>0) and (z[x+1,y]<>1)then color(x+1,y,w);
if (r[x+1,y-1]<>0) and (z[x+1,y-1]<>1)then color(x+1,y-1,w);
if (r[x,y-1]<>0) and (z[x,y-1]<>1)then color(x,y-1,w);
if (r[x-1,y-1]<>0) and (z[x-1,y-1]<>1)then color(x-1,y-1,w);
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; end;
{=================================================}
ys:=0; zd:=0;
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,ys);
end;
{=================================================}
write(ys);
{=================================================}
close(input);
close(output);
end.