比赛 |
20091103 |
评测结果 |
AAAAAAAAAAW |
题目名称 |
乳草的入侵 |
最终得分 |
90 |
用户昵称 |
打不死的羊 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-03 10:11:45 |
显示代码纯文本
program milkweed;
const
cx:array[1..8] of longint=(0,0,1,1,1,-1,-1,-1);
cy:array[1..8] of longint=(1,-1,1,-1,0,1,-1,0);
type
fxz1=array[1..100,1..100]of boolean;
fxz2=array[1..100000] of longint;
var
f1,f2:text;
i,j,n,m,x,y,ans,t,w,ww:longint;
ch:char;
map:fxz1;
xx,yy:fxz2;
begin assign(f1,'milkweed.in');
assign(f2,'milkweed.out');
reset(f1);rewrite(f2);
readln(f1,m,n,y,x);
for i:=1 to n do
for j:=1 to m do map[i,j]:=false;
for i:=1 to n do
begin for j:=1 to m do
begin read(f1,ch);
if ch='.' then map[i,j]:=true;
end;
readln(f1);
end;
xx[1]:=x;yy[1]:=y;t:=1;w:=1;
ans:=-1;
repeat inc(ans);
ww:=w;
for i:=t to w do
for j:=1 to 8 do if (xx[i]+cx[j]>0)and(xx[i]+cx[j]<=n)and(yy[i]+cy[j]>0)and(yy[i]+cy[j]<=m) then
if map[xx[i]+cx[j],yy[i]+cy[j]] then
begin inc(ww);
xx[ww]:=xx[i]+cx[j];
yy[ww]:=yy[i]+cy[j];
map[xx[i]+cx[j],yy[i]+cy[j]]:=false;
end;
t:=w+1;
w:=ww;
until t>w;
writeln(f2,ans);
close(f1);close(f2);
end.