QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#727749#7866. TeleportationLuCiiiDCompile Error//C++231.0kb2024-11-09 13:43:322024-11-09 13:43:34

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 13:43:34]
  • 评测
  • [2024-11-09 13:43:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define _11037_ ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define endl '\n'
#define MAX 100005
#define MOD 998244353
int N, X, a[MAX];
int BFS(int start)
{
    int book[MAX];
    for (int i = 0; i < MAX; i++)
        book[i] = inf;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    que.push({0, 0}), book[0] = 0;
    while (que.size())
    {
        int nowstep = que.top().first, now = que.top().second;
        if (now == X)
            return book[X];
        que.pop();
        for (int i = 0; i < N; i++)
        {
            if (book[(now + a[now] + i) % N] < nowstep + i + 1)
                continue;
            book[(now + a[now] + i) % N] = nowstep + i + 1;
            que.push({nowstep + i + 1, (now + a[now] + i) % N});
        }
    }
    return book[X];
}
signed main()
{
    _11037_
    cin >> N >> X;
    for (int i = 0; i < N; i++)
        cin >> a[i];
    cout << BFS(0) << endl;
}

詳細信息

answer.code: In function ‘int BFS(int)’:
answer.code:12:19: error: ‘inf’ was not declared in this scope; did you mean ‘ynf’?
   12 |         book[i] = inf;
      |                   ^~~
      |                   ynf