#include<bits/stdc++.h>
using namespace std;
bool vis[205];
int ans[205],k[205],A,B,N;
void dfs(int fl,int cnt){
if(fl>N||fl<1)return;
if(vis[fl])return;
ans[fl]=min(ans[fl],cnt);
vis[fl]=1;
}
int main()
{
for(int i=0;i<=204;i++)ans[i]=100000000;
memset(vis,0,sizeof(vis));
cin>>N>>A>>B;
for(int i=1;i<=N;i++)cin>>k[i];
dfs(A,0);
if(ans[B]==100000000){
cout<<"-1";
exit(0);
}
cout<<ans[B];
exit(0);
}
结果
求大佬指正
QAQAQAQAQ