QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296666 | #7866. Teleportation | sjw712 | WA | 0ms | 3604kb | C++14 | 984b | 2024-01-03 12:57:47 | 2024-01-03 12:57:47 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, x; cin >> n >> x;
vector<vector<int>> G(n);
for (int i = 1; i < n - 1; ++i) G[i].emplace_back(i + 1);
G[n - 1].emplace_back(0);
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
G[i].emplace_back((i + a[i]) % n);
}
queue<int> Q;
vector<int> dis(n, INF);
Q.push(0);
dis[0] = 0;
while (Q.size()) {
int u = Q.front(); Q.pop();
for (int v: G[u]) {
if (dis[v] == INF) {
dis[v] = dis[u] + 1;
Q.push(v);
}
}
}
cout << dis[x] << el;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3604kb
input:
4 3 0 1 2 3
output:
1061109567
result:
wrong answer 1st numbers differ - expected: '4', found: '1061109567'