比赛 |
20091103 |
评测结果 |
AAWWWWAAWWA |
题目名称 |
乳草的入侵 |
最终得分 |
45 |
用户昵称 |
reamb |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-03 11:29:32 |
显示代码纯文本
program caodituozhanwenti;
var
c,x,t,y,mx,w,my,i,j:integer;
bz:boolean;
a:array[0..101,0..101]of integer;
b:char;
begin
assign (input,'milkweed.in');
reset (input);
assign (output,'milkweed.out');
rewrite (output);
readln (x,y,mx,my);
for i:=1 to y do
begin
for j:=1 to x do
begin
read (b);
if b='*' then
begin
a[i,j]:=0;
w:=w+1
end
else
a[i,j]:=-1
end;
readln
end;
a[mx,my]:=1;
t:=t+1;
repeat
t:=t+1;
bz:=true;
for i:=1 to y do
for j:=1 to x do
if a[i,j]=t-1 then
begin
if a[i,j-1]=-1 then
begin
bz:=false;
a[i,j-1]:=t
end;
if a[i,j+1]=-1 then
begin
bz:=false;
a[i,j+1]:=t
end;
if a[i-1,j]=-1 then
begin
bz:=false;
a[i-1,j]:=t
end;
if a[i+1,j]=-1 then
begin
bz:=false;
a[i+1,j]:=t
end;
if a[i-1,j-1]=-1 then
begin
bz:=false;
a[i-1,j-1]:=t
end;
if a[i-1,j+1]=-1 then
begin
bz:=false;
a[i-1,j+1]:=t
end;
if a[i+1,j-1]=-1 then
begin
bz:=false;
a[i+1,j-1]:=t
end;
if a[i+1,j+1]=-1 then
begin
bz:=false;
a[i+1,j+1]:=t
end
end;
if bz=true then
begin
writeln ('-1');
close (input);
close (output);
halt
end;
c:=0;
for i:=1 to y do
for j:=1 to x do
if a[i,j]>0
then c:=c+1
until c=x*y-w;
writeln (t-1);
close (input);
close (output)
end.