帮忙看下哪错了.....搜索不过关
状态: Unaccepted
测评机: Xeond[6]
得分: 60分
提交日期: 2010-7-14 15:00:00
有效耗时: 406毫秒
测试结果1: 通过本测试点|有效耗时172ms
测试结果2: 通过本测试点|有效耗时47ms
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 通过本测试点|有效耗时47ms
测试结果5: 通过本测试点|有效耗时46ms
测试结果6: 输出过长|用户输出数据超过标准输出两倍[标准输出2位|选手输出12位]
测试结果7: 通过本测试点|有效耗时47ms
测试结果8: 运行错误|栈溢出
测试结果9: 选手程序运行超过时限
测试结果10: 运行错误|栈溢出
const
d:array[1..4,1..2]of integer=((1,0),(0,1),(-1,0),(0,-1));
var
n,m,i,j,ans:longint;
map:array[0..101,0..101]of char;
door:array['A'..'Z',1..4]of longint;
ok:array[0..101,0..101]of boolean;
procedure go(x,y,s:longint);
var
i,x1,y1:longint;
begin
if s>=ans
then exit;
if (x=n)and(y=m)
then begin
ans:=s;
exit;
end;
for i:=1 to 4 do
begin
x1:=x+d[i,1];
y1:=y+d[i,2];
if not ok[x1,y1]
then continue;
if map[x1,y1]='0'
then begin
ok[x,y]:=false;
go(x1,y1,s+1);
ok[x,y]:=true;
end
else if (map[x1,y1]>='A')and(map[x1,y1]<='Z')
then begin
ok[x,y]:=false;
ok[x1,y1]:=false;
if (door[map[x1,y1],3]=x1)and(door[map[x1,y1],4]=y1)
then go(door[map[x1,y1],1],door[map[x1,y1],2],s+1)
else go(door[map[x1,y1],3],door[map[x1,y1],4],s+1);
ok[x,y]:=true;
ok[x1,y1]:=true;
end;
end;
end;
begin
readln(n,m);
fillchar(ok,sizeof(ok),true);
FILLCHAR(door,sizeof(door),0);
for i:=1 to n do
begin
for j:=1 to m do
begin
read(map[i,j]);
if (map[i,j]>='A')and(map[i,j]<='Z')
then begin
if door[map[i,j],3]=0 //对应该字母的两扇传送门的坐标
then begin
door[map[i,j],3]:=i;
door[map[i,j],4]:=j;
end
else begin
door[map[i,j],1]:=i;
door[map[i,j],2]:=j;
end;
end;
end;
readln;
end;
ans:=maxlongint;
go(1,1,0);
if ans<>maxlongint
then writeln(ans)
else writeln('No Solution.');
end.