QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#728287 | #7866. Teleportation | nekoyellow | WA | 0ms | 3844kb | C++23 | 710b | 2024-11-09 14:54:33 | 2024-11-09 14:54:34 |
Judging History
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