讨论 / 大家看下,为什么有一个点WA
fjxmlhx 2010-09-22 21:53:00
点我顶贴 收藏 删除
var

n,i,x,wei,tou,total,y:longint;

c,a:array[0..200] of longint;

b:array[1..40000,1..2] of longint;

procedure can(l,r:longint);

begin

wei:=wei mod 40000 +1;

c[l]:=1;

b[wei,1]:=l;

b[wei,2]:=r+1;

if b[wei,1]=y then begin write(b[wei,2]);halt;end;

inc(total);

end;

begin

readln(n,x,y);

if n=1 then begin write(1);halt;end;

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

b[1,1]:=x;

wei:=1;

c[1]:=1;

tou:=1;

repeat

if b[tou,1]=y then begin write(b[tou,2]);halt;end

else

begin

if (b[tou,1]-a[b[tou,1]]>=1)then begin if (c[(b[tou,1]-a[b[tou,1]])]=0) then can(b[tou,1]-a[b[tou,1]],b[tou,2]); end;

if (b[tou,1]+a[b[tou,1]]<=n)then begin if (c[(b[tou,1]+a[b[tou,1]])]=0)then can(b[tou,1]+a[b[tou,1]],b[tou,2]); end;

end;

tou:=tou mod 40000 +1;dec(total);

until total<0;

write(-1);

end.

#1 我不是白痴@2010-09-22 21:52:00
回复 删除
a=B
#2 lyc@2010-09-22 21:53:00
回复 删除
Are you sure?
查看更多回复
提交回复