第一点TLE
https://www.luogu.com.cn/record/134136130
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, a, b, k[222], ans = LONG_LONG_MAX;
bool v[222];
void dfs(int x, int s) {
if (x >= 1 and x <= n and !v[x] and s <= ans) {
if (x == b) {
ans = min(ans, s);
return;
}
v[x] = 1;
dfs(x + k[x], s + 1);
dfs(x - k[x], s + 1);
v[x] = 0;
}
}
signed main() {
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) {
cin >> k[i];
}
dfs(a, 0);
if (ans == LONG_LONG_MAX) {
cout << -1;
} else {
cout << ans;
}
}