求调!!!
QAQ
#include<bits/stdc++.h>
using namespace std;
int n,a,b,k[210],q[210][2],hd,tl;
bool f[210];
int main(){
cin>>n>>a>>b;
for(int i=1;i<=n;i++){
cin>>k[i];
}
if(a==b){
puts("0");
return 0;
}
hd=0,tl=1;
q[1][0]=a,q[1][1]=0;
f[a]=true;
while(hd<tl){
hd++;
for(int i=-1;i<=1;i+=2){
int y=q[hd][0]+i*k[q[hd][0]];
if(y<1||y>n||f[y]){
continue;
}
if(y==b){
cout<<q[hd][1]+1;
return 0;
}
f[y]=true;
++tl;
q[tl][0]=y;
q[tl][1]=q[hd][1]+1;
}
}
puts("1");
return 0;
}