讨论 / WA70 请问哪错了?
shengyangweb 2013-05-25 09:16:00
点我顶贴 收藏 删除
Program Wow;

const x:array[1..4] of integer=(-1,1,0,0);

y:array[1..4] of integer=(0,0,-1,1);

maxn=100;

type board=array[1..maxn,1..maxn] of char;

quenetype=record

step:longint;

xx,yy:byte;

end;

var q:array[1..100000] of quenetype;

head,tail:longint;

flag:array[1..maxn,1..maxn] of boolean;

m,n:longint;

map:board;

Procedure Initial;

var i,j:integer;

begin

fillchar(flag,sizeof(flag),false);

head:=1;tail:=1;

q[head].xx:=1;

q[head].yy:=1;

readln(n,m);

for i:=1 to n do

begin

for j:=1 to m do

read(map[i,j]);

readln;

end;

end;

Function Judge(qx,qy:byte;i:byte):boolean;

begin

if (qx>0)and(qx<=n)and(qy>0)and(qy<=m) then

exit(true);

exit(false);

end;

Procedure Search(remap:board;qx,qy:byte);

var i,j:byte;

ch:char;

begin

ch:=remap[qx,qy];

remap[qx,qy]:='@';

for i:=1 to n do

for j:=1 to m do

if remap[i,j]=ch then

begin

inc(tail);

q[tail].xx:=i;

q[tail].yy:=j;

q[tail].step:=q[head].step+1;

exit;

end;

end;

Procedure Main;

var i,qx,qy:longint;

begin

while head<=tail do

begin

flag[q[head].xx,q[head].yy]:=true;

for i:=1 to 4 do

begin

qx:=q[head].xx+x[i];

qy:=q[head].yy+y[i];

if judge(qx,qy,i) then

begin

if flag[qx,qy] then continue;

if (qx=n)and(qy=m) then

begin

writeln(q[head].step+1);

halt;

end;

if map[qx,qy]<>'1' then

if map[qx,qy]='0' then

begin

flag[qx,qy]:=true;

inc(tail);

q[tail].xx:=qx;

q[tail].yy:=qy;

q[tail].step:=q[head].step+1;

end

else

search(map,qx,qy)

end;

end;

inc(head);

end;

writeln('No Solution.');

end;

begin

Initial;

Main;

end.

测试结果1: 通过本测试点|有效耗时172ms

测试结果2: 通过本测试点|有效耗时47ms

测试结果3: 通过本测试点|有效耗时47ms

测试结果4: 通过本测试点|有效耗时46ms

测试结果5: 通过本测试点|有效耗时47ms

测试结果6: 输出过长|用户输出数据超过标准输出两倍[标准输出2位|选手输出12位]

测试结果7: 通过本测试点|有效耗时47ms

测试结果8: 通过本测试点|有效耗时203ms

测试结果9: 输出过长|用户输出数据超过标准输出两倍[标准输出3位|选手输出12位]

测试结果10: 输出过长|用户输出数据超过标准输出两倍[标准输出3位|选手输出12位]

#1 shengyangweb@2011-01-10 06:31:00
回复 删除
AC了。。。

如果有大牛看出哪错了的,依然给分。。。

#2 卍编程时代卍@2011-01-17 17:37:00
回复 删除
。。。
#3 郁闷ING@2011-02-09 01:43:00
回复 删除
每个点要判断是否访问多次
#4 fshp97@2013-05-25 09:16:00
回复 删除
求LZ的修改方法...

wa80,6&7输出no solution...

查看更多回复
提交回复