QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#727726#7866. TeleportationLuCiiiDTL 5ms11636kbC++231.0kb2024-11-09 13:40:142024-11-09 13:40:15

Judging History

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

  • [2024-11-09 13:40:15]
  • 评测
  • 测评结果:TL
  • 用时:5ms
  • 内存:11636kb
  • [2024-11-09 13:40:14]
  • 提交

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 int long long
#define inf 4e18
#define MAX 1000005
#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;
        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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 11356kb

input:

4 3
0 1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 11360kb

input:

4 3
0 0 0 0

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 4ms
memory: 11580kb

input:

4 3
2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 0ms
memory: 11356kb

input:

2 1
0 0

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 11616kb

input:

2 1
1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 5ms
memory: 11636kb

input:

300 25
182 9 13 211 258 132 27 42 218 200 271 258 164 121 8 84 29 195 141 290 110 0 272 93 142 134 140 32 232 99 162 199 297 287 212 29 182 53 61 98 116 282 75 245 230 165 22 4 179 89 274 231 46 299 248 208 200 285 221 50 221 199 294 241 195 138 22 204 113 100 132 276 158 146 238 178 100 94 131 157 ...

output:

10

result:

ok 1 number(s): "10"

Test #7:

score: -100
Time Limit Exceeded

input:

300 49
5 0 5 6 8 1 2 6 8 8 0 7 0 0 2 0 7 3 6 0 7 2 6 4 3 9 9 6 5 0 9 1 4 1 5 2 5 5 2 5 5 5 9 9 2 7 0 0 6 6 9 7 10 3 5 2 6 3 0 8 6 4 4 9 7 4 8 0 2 4 5 0 6 5 7 0 9 5 1 3 9 2 3 5 8 2 0 1 0 8 2 4 5 1 10 8 8 8 5 3 1 7 6 8 10 1 6 5 8 2 1 1 10 1 5 1 6 1 7 5 3 3 6 8 8 6 2 0 4 9 7 1 8 5 9 5 0 3 1 8 0 0 2 8 0...

output:


result: