3406: [Usaco2009 Oct]Invasion of the Milkweed 乳草的入侵

时间:2024-11-24 20:33:38

3406: [Usaco2009 Oct]Invasion of the Milkweed 乳草的入侵

Time Limit: 3 Sec  Memory Limit: 128 MB
Submit: 87  Solved: 49
[Submit][Status][Discuss]

Description

3406: [Usaco2009 Oct]Invasion of the Milkweed 乳草的入侵

Input

  第1行:4个由空格隔开的整数X,K Mx,My.
    第2到第Y+1行:每行由X个字符描述草地.

Output

    一个单独的整数表示最后一个不是大石块的格子被乳草占领的星期数

Sample Input

4 3 1 1
....
..*.
.**.

Sample Output

4

HINT

Source

题解:题目本身很水,一道灌水法,BFS秒杀
但还是WA了一下,表示题目描述简直坑爹不解释,注意看清题目描述再下手(还有OI经常很良心的让你就算题目理解错了也能过样例TT)
 /**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ const dir:array[..,..] of longint=((,),(-,),(,),(,-),(,),(-,-),(-,),(,-));
var
i,j,k,l,m,n,x,y,x0,y0,f,r:longint;
a:array[..,..] of longint;
d:array[..,..] of longint;
ch:char;
begin
readln(m,n,y,x);x:=n+-x;
for i:= to n+ do
begin
a[i,m+]:=;
a[i,]:=;
end;
for i:= to m+ do
begin
a[n+,i]:=;
a[,i]:=;
end;
for i:= to n do
for j:= to m do
begin
read(ch);
if ch='.' then a[i,j]:= else a[i,j]:=;
if j=m then readln;
end;
d[,]:=x;d[,]:=y;d[,]:=;f:=;r:=;
while f<r do
begin
for i:= to do
begin
x0:=d[f,]+dir[i,];
y0:=d[f,]+dir[i,];
if a[x0,y0]= then
begin
d[r,]:=x0;
d[r,]:=y0;
d[r,]:=d[f,]+;
inc(r);a[x0,y0]:=;
end;
end;
inc(f);
end;
writeln(d[f-,]);
readln;
end.