P1135 奇怪的电梯
神马玩意
#include <bits/stdc++.h>
using namespace std;
int n, a,b,d=0;
int m[205];
void bfs() {
int t;
queue<int> q;
q.push(a);
while(!q.empty()) {
int h=q.front();
if(h==b) break;
q.pop();
if(h < 1 || h > n) continue;
q.push(h+m[h]);
q.push(h-m[h]);
d++;
}
}
int main() {
cin >> n >> a>>b;
for(int i = 1; i <= n; i++) cin >> m[i];
bfs();
cout<<d;
return 0;
}