讨论 / 谁说广搜超时啦?
DarkMaster 2009-05-09 01:21:00
点我顶贴 收藏 删除
这题朴素的广搜即可。谁说BFS超时?

状态题目:紧急援救

题目编号:34-紧急援救 查看该题

状态: Accepted

测评机: Xeond[6]

得分: 100分

提交日期: 2008-8-20 20:01:00

有效耗时: 2017毫秒

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

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

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

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

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

测试结果6: 通过本测试点|有效耗时250:ms

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

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

测试结果9: 通过本测试点|有效耗时250:ms

测试结果10: 通过本测试点|有效耗时250:ms

#1 Mato完整版@2008-08-20 07:21:00
回复 删除
我的程序说后面8组全都走不通……
#2 DarkMaster@2008-08-21 20:10:00
回复 删除
什么意思?
#3 Mato完整版@2008-08-26 01:38:00
回复 删除
而且是第一步就走不通。
#4 webeskycn@2009-05-08 06:53:00
回复 删除
我也超时了。。。

why。。。

#5 小小小学生@2009-05-09 01:21:00
回复 删除
你们应该是编错了才超时的吧?!
#6 小小小学生@2009-05-09 01:21:00
回复 删除
program li;

const c:array[1..4,1..2] of longint=((-1,0),(1,0),(0,1),(0,-1));

var n,x,y,x1,y1,x2,y2:longint;

a:array[0..1001,0..1001] of char;

b:array[0..1000000,1..3] of longint;

procedure init;

var i,j:longint;

begin

readln(n);

for i:=1 to n do

begin

for j:=1 to n do read(a[i,j]); readln;

end;

readln(x1,y1); readln(x2,y2);

end;

procedure work;

var i,tp1,tp2:longint;

begin

tp1:=1; tp2:=1;

fillchar(b,sizeof(b),0);

a[x1,y1]:=’1’; b[1,1]:=x1; b[1,2]:=y1;

while tp1<=tp2 do

begin

x:=b[tp1,1]; y:=b[tp1,2];

for i:=1 to 4 do

begin

x:=x+c[i,1]; y:=y+c[i,2];

if (x>0) and (x<=n)and (y>0)and (y<=n)and (a[x,y]=’0’) then

begin

inc(tp2);

b[tp2,1]:=x; b[tp2,2]:=y;

b[tp2,3]:=b[tp1,3]+1;

a[x,y]:=’1’;

if (x=x2)and (y=y2) then begin writeln(b[tp2,3]); halt; end;

end;

x:=x-c[i,1]; y:=y-c[i,2];

end;

inc(tp1);

end;

end;

begin

init;

work;

end.

查看更多回复
提交回复