QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#761556#7866. TeleportationNiggerRE 0ms0kbC++14993b2024-11-19 00:44:092024-11-19 00:44:10

Judging History

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

  • [2024-11-19 00:44:10]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-19 00:44:09]
  • 提交

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

output:


result: