QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#728287#7866. TeleportationnekoyellowWA 0ms3844kbC++23710b2024-11-09 14:54:332024-11-09 14:54:34

Judging History

This is the latest submission verdict.

  • [2024-11-09 14:54:34]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3844kb
  • [2024-11-09 14:54:33]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &e: a)
        cin >> e;

    vector<set<int>> g(n);
    for (int i = 0; i < n; i++) {
        g[i].emplace((i+1)%n);
        g[i].emplace((i+a[i])%n);
    }

    queue<pair<int, int>> q;
    q.push({0, 0});
    while (q.size()) {
        auto [u, c] = q.front(); q.pop();
        for (auto v: g[u]) {
            if (c == 0 && v == 1) continue;
            if (v == k) {
                cout << c+1 << endl;
                return 0;
            }
            q.push({v, c+1});
        }
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 3
0 1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

4 3
0 0 0 0

output:

4

result:

ok 1 number(s): "4"

Test #3:

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

input:

4 3
2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

2 1
0 0

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3608kb

input:

2 1
1 1

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements