比赛 |
20091103 |
评测结果 |
AWWWWWWWWWW |
题目名称 |
乳草的入侵 |
最终得分 |
9 |
用户昵称 |
chengyang |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-03 10:36:19 |
显示代码纯文本
program milkweed;
var
map:array[0..101,0..101]of longint;
ma:array[0..101,0..101] of boolean;
i,j,n,m,a,b,t,X:longint;
s:string;
procedure sss;
var
i,j:longint;
begin
X:=0;
for i:=1 to m do begin
for j:=1 to n do begin
if (ma[i,j])and(map[i,j]<>-1) then begin
INC(X);
if map[i+1,j]=0 then begin
ma[i+1,j]:=true;
map[i+1,j]:=map[i,j]+1;
if t<map[i,j] then t:=map[i,j]+1;
end;
if map[i-1,j]=0 then begin
ma[i-1,j]:=true;
map[i-1,j]:=map[i,j]+1;
if t<map[i,j] then t:=map[i,j]+1;
end;
if map[i+1,j+1]=0 then begin
ma[i+1,j+1]:=true;
map[i+1,j+1]:=map[i,j]+1;
if t<map[i,j] then t:=map[i,j]+1;
end;
if map[i+1,j-1]=0 then begin
ma[i+1,j-1]:=true;
map[i+1,j-1]:=map[i,j]+1;
if t<map[i,j] then t:=map[i,j]+1;
end;
if map[i,j+1]=0 then begin
ma[i,j+1]:=true;
map[i,j+1]:=map[i,j]+1;
if t<map[i,j] then t:=map[i,j]+1;
end;
if map[i,j-1]=0 then begin
ma[i,j-1]:=true;
map[i,j-1]:=map[i,j]+1;
if t<map[i,j] then t:=map[i,j]+1;
end;
if map[i-1,j+1]=0 then begin
ma[i-1,j+1]:=true;
map[i-1,j+1]:=map[i,j]+1;
if t<map[i,j] then t:=map[i,j]+1;
end;
if map[i-1,j-1]=0 then begin
ma[i-1,j+1]:=true;
map[i-1,j+1]:=map[i,j]+1;
if t<map[i,j] then t:=map[i,j]+1;
end;
ma[i,j]:=false;
END;
END;
end;
end;
begin
assign(input,'milkweed.in');
assign(output,'milkweed.out');
reset(input); rewrite(output);
readln(n,m,a,b);
t:=0;
for i:=0 to 101 do begin
for j:=0 to 101 do begin
map[i,j]:=-1;
ma[i,j]:=false;
end;
end;
for i:=1 to m do begin
readln(s);
for j:=1 to n do if s[j]='.' then map[i,j]:=0 ;
end;
map[m-b+1,a]:=1; ma[m-b+1,a]:=true;
for i:=1 to n*m do begin
SSS;
if x=0 then break;
end;
for i:=1 to n do begin
for j:=1 to m do begin
if map[j,i]=0 then begin
writeln(-1);
halt;
close(input); close(output);
end;
end;
end;
writeln(t);
close(input); close(output);
end.