QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#761556 | #7866. Teleportation | Nigger | RE | 0ms | 0kb | C++14 | 993b | 2024-11-19 00:44:09 | 2024-11-19 00:44:10 |
answer
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define pb push_back
#define mp make_pair
#define READS(x); string x;cin >> x;
#define READ(x); int x;cin >> x;
#define DOUREAD(x,y); int x,y;cin >> x >> y;
#define TRIREAD(x,y,z); int x,y,z;cin >> x >> y >> z;
const int MAXN = 1e5+69;
int VIS[MAXN],DIS[MAXN],A[MAXN];
int N,X;
signed main(){fast
cin >> N >> X;
for(int i = 0; i < N ; i++) cin >> A[i];
queue<int> Q;
VIS[A[0]] = 1;
DIS[A[0]] = 1;
Q.push(A[0]);
while(!Q.empty()){
auto Z = Q.front();
Q.pop();
int N1 = Z+1;
if(VIS[N1] == 0){
VIS[N1] = 1;
DIS[N1] = DIS[Z] + 1;
Q.push(N1);
}
int N2 = (Z+A[Z])%N;
if(VIS[N2] == 0){
VIS[N2] = 1;
DIS[N2] = DIS[Z] + 1;
Q.push(N2);
}
}
cout << DIS[X] << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
4 3 0 1 2 3