QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#310028 | #7866. Teleportation | SolitaryDream | WA | 0ms | 3564kb | C++17 | 559b | 2024-01-21 00:07:18 | 2024-01-21 00:07:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1e3+7;
int n,x,a[N],d[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>x;
for(int i=0;i<n;i++)
cin>>a[i],d[i]=-1;
queue<int> q;
q.push(a[0]);
d[a[0]]=0;
while(!q.empty())
{
int x=q.front();
q.pop();
for(auto v:{(x+a[x])%n,(x+1)%n})
{
if(d[v]!=-1)
continue;
d[v]=d[x]+1;
q.push(v);
}
}
cout<<d[x]<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
4 3 0 1 2 3
output:
3
result:
wrong answer 1st numbers differ - expected: '4', found: '3'