记录编号 |
26816 |
评测结果 |
AAWTT |
题目名称 |
管道系统 |
最终得分 |
40 |
用户昵称 |
老虎小飞 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
2.001 s |
提交时间 |
2011-07-27 14:50:21 |
内存使用 |
0.12 MiB |
显示代码纯文本
const
u:array[1..4]of longint=(0,0,1,-1);
v:array[1..4]of longint=(1,-1,0,0);
a:array[0..14,1..4]of boolean=(
(false,false,false,false),
(true,true,false,false),
(false,false,true,true),
(true,false,true,false),
(false,true,true,false),
(false,true,false,true),
(true,false,false,true),
(true,true,true,false),
(false,true,true,true),
(true,true,false,true),
(true,false,true,true),
(true,true,true,true),
(true,true,true,true),
(true,true,true,true),
(true,true,true,true));
var
f:array[1..6,1..6,1..2]of boolean;
n,m,i,j,ans,k,l:longint;
x0,y0,xx,yy,c0,cc:longint;
ccc:char;
map:array[0..6,0..6]of longint;
procedure sou(x0,y0,c0:longint);
var
i,c,x,y,j:longint;
begin
case map[x0,y0] of
0,1,2,3,4,5,6,7,8,9,10,11:begin
f[x0,y0,1]:=true;
end;
12:begin
if (c0=1)or(c0=2) then begin
f[x0,y0,1]:=true;
end
else begin
f[x0,y0,2]:=true;
end;
end;
13:begin
if (c0=1)or(c0=3) then begin
f[x0,y0,1]:=true;
end
else begin
f[x0,y0,2]:=true;;
end;
end;
14:begin
if (c0=1)or(c0=4) then begin
f[x0,y0,1]:=true;
end
else begin
f[x0,y0,2]:=true;;
end;
end;
end;
for i:=1 to 4 do begin
case i of
1:x:=2;2:x:=1;3:x:=4;4:x:=3;end;
if (x=c0)or(not a[map[x0,y0],x]) then continue;
if (map[x0,y0]=12)and( abs(x-c0)<>1 ) then continue;
if (map[x0,y0]=13)and( abs(x-c0)<>2 ) then continue;
if (map[x0,y0]=14)and( not((x*c0=6)or(x*c0=4)) ) then continue;
x:=x0+u[i];y:=y0+v[i];
if (x=xx)and(y=yy)and(i=cc) then begin
inc(ans);
end;
if (x>0)and(x<=n)and(y>0)and(y<=m) then begin
if a[map[x,y],i] then begin
case map[x,y] of
0,1,2,3,4,5,6,7,8,9,10,11:begin
if f[x,y,1] then continue;
end;
12:begin
if (i=1)or(i=2) then begin
if f[x,y,1] then continue;
end
else begin
if f[x,y,2] then continue;
end;
end;
13:begin
if (i=1)or(i=3) then begin
if f[x,y,1] then continue;
end
else begin
if f[x,y,2] then continue;
end;
end;
14:begin
if (i=1)or(i=4) then begin
if f[x,y,1] then continue;
end
else begin
if f[x,y,2] then continue;
end;
end;
end;
sou(x,y,i);
end;
end;
end;
case map[x0,y0] of
0,1,2,3,4,5,6,7,8,9,10,11:begin
f[x0,y0,1]:=false;
end;
12:begin
if (c0=1)or(c0=2) then begin
f[x0,y0,1]:=false;
end
else begin
f[x0,y0,2]:=false;
end;
end;
13:begin
if (c0=1)or(c0=3) then begin
f[x0,y0,1]:=false;
end
else begin
f[x0,y0,2]:=false;;
end;
end;
14:begin
if (c0=1)or(c0=4) then begin
f[x0,y0,1]:=false;
end
else begin
f[x0,y0,2]:=false;;
end;
end;
end;
end;
begin
assign(input,'paipe.in'); reset(input);
assign(output,'paipe.out'); rewrite(output);
while not eof do begin
read(m,n);
for i:=1 to m do
for j:=1 to n do read(map[j,i]);
read(y0,x0);
read(ccc);read(ccc);
case ccc of
'U':c0:=1;
'D':c0:=2;
'L':c0:=3;
'R':c0:=4;
end;
read(yy,xx);
read(ccc);read(ccc);
case ccc of
'U':begin cc:=2;dec(yy);end;
'D':begin cc:=1;inc(yy);end;
'L':begin cc:=4;dec(xx);end;
'R':begin cc:=3;inc(xx);end;
end;
readln;
ans:=0;
if a[map[x0,y0],c0] then
sou(x0,y0,c0);
writeln(ans);
end;
close(input);close(output);
end.