JZXX
ACwing
ACmore
网址很多,不写题面了。
Pascal代码(难得来一发Pascal):
{
bfs大法一招过
}
const dir:array[1..8,1..2] of longint=((1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1),(-1,1),(1,-1));
var
i,j,k,l,m,n,x,y,x0,y0,f,r:longint;
a:array[0..101,0..101] of longint;
d:array[0..15000,1..3] of longint;
ch:char;
begin
readln(m,n,y,x);x:=n+1-x;
for i:=0 to n+1 do
begin
a[i,m+1]:=1;
a[i,0]:=1;
end;
for i:=0 to m+1 do
begin
a[n+1,i]:=1;
a[0,i]:=1;
end;
for i:=1 to n do
for j:=1 to m do
begin
read(ch);
if ch='.' then a[i,j]:=0 else a[i,j]:=1;
if j=m then readln;
end;
d[1,1]:=x;d[1,2]:=y;d[1,3]:=0;f:=1;r:=2;
while f
JZXX完美的C++代码:
#include
using namespace std;
int X,Y,mx,my;
string g[1000+5];
int dir[8][2]={{1,0},{1,-1},{1,1},{-1,0},{-1,1},{-1,-1},{0,1},{0,-1}};
struct node
{
int y,x,t;
node(){};
node(int _y,int _x,int _t)
{
y=_y;
x=_x;
t=_t;
}
};
queue qu;
bool in(int y,int x)
{
return 0<=y&&y>X>>Y>>mx>>my;
for(int i=Y-1;i>=0;i--)
cin>>g[i];
cout<