代码:
#include<bits/stdc++.h>
using namespace std;
int e[100010],r[100010];
queue<int> q;
int main()
{
int n,b,a,t,k,s = 0;
cin>>n>>a>>b;
for(int i = 1;i <= n;i++)
cin>>e[i];
q.push(a);
while(!q.empty())
{
int x = q.front();
if(x == b)
{
cout<<s<<endl;
return 0;
}
q.pop();
if(x - e[x] > 0)
q.push(x - e[x]);
if(x + e[x] <= n)
q.push(x + e[x]);
s++;
}
cout<<1<<endl;
return 0;
}