📄 ac1256.pas
字号:
program tju1256;
const
maxn=200;
var
k,q,step:array[1..maxn]of byte;
n,b,i,f,r:longint;
begin
repeat
read(n,q[1],b);
for i:=1 to n do read(k[i]);
fillchar(step,sizeof(step),255);step[q[1]]:=0;
f:=0;r:=1;
repeat
inc(f);
i:=q[f]+k[q[f]];
if (i<=n) and (step[i]=255) then begin
step[i]:=step[q[f]]+1;if i=b then break;inc(r);q[r]:=i;
end;
i:=q[f]-k[q[f]];
if (i>0) and (step[i]=255) then begin
step[i]:=step[q[f]]+1;if i=b then break;inc(r);q[r]:=i;
end;
until f=r;
if step[b]<255 then writeln(step[b]) else writeln(-1);
until seekeof;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -