QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#310028#7866. TeleportationSolitaryDreamWA 0ms3564kbC++17559b2024-01-21 00:07:182024-01-21 00:07:19

Judging History

你现在查看的是最新测评结果

  • [2024-01-21 00:07:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2024-01-21 00:07:18]
  • 提交

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'