跳到正文

ShantaramPT2

1450302

MCX

在洛谷打开
资料、奖项与版本

资料

编号
1450302
抓取
C++
#include <bits/stdc++.h>
using namespace std;
int n, a, b, k[205];
int vis[205], dis[205];
queue<int>q;
void bfs(int x)
{
	q.push(x);
	vis[x] = 1;
	while(!q.empty())
	{
		int now = q.fornt();
		if (now == b)
		{
			cout << dis[now];
			exit(0);
		}
		q.pop();
		if(x + k[x] <= n)
		{
			q.push
		}
	}
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++)
    {
    	cin >> k[i];
	}
	bfs(a);
	cout << "-1"; 
    return 0;
}

还没有收录这位用户的文章。