QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#650202#7866. TeleportationMrlaolu#WA 0ms3868kbC++231.0kb2024-10-18 13:56:312024-10-18 13:56:31

Judging History

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

  • [2024-10-18 13:56:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3868kb
  • [2024-10-18 13:56:31]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

using PII = pair<int,int>;
struct s{
    int p,a,cnt;
};
void solve(){
    int n,x;cin >> n >> x;
    vector<int>a(n);
    for(int i = 0;i < n;++i)cin >> a[i];
    queue<s>que;
    int ans = 0;
    vector<bool>vis(n+1);
    vector<bool>pass(n+1);
    vis[0] = 1,pass[0] = 0;
    que.push({0,a[0],0});
    while(que.size()){
        s t = que.front();
        que.pop();
        if((t.a + t.p) % n == x){ans = t.cnt + 1;break;}
        if(!vis[(t.a + t.p) % n]){
            vis[(t.a + t.p) % n] = 1;
            que.push({(t.a + t.p) % n,a[(t.a + t.p) % n],t.cnt+1});
        }
        if(!pass[(t.a + t.p + 1) % n] && !vis[t.a + t.p + 1] % n){
            pass[(t.a + t.p + 1) % n] = 1;
            que.push({t.p,(t.a+1) % n,t.cnt+1});
        }
    }

    cout << ans << endl;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    while(_--){
        solve();
    }
}
/*
5 2
3 0 0 4 0
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

input:

4 3
0 1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

4 3
0 0 0 0

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

4 3
2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

2 1
0 0

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

2 1
1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3868kb

input:

300 25
182 9 13 211 258 132 27 42 218 200 271 258 164 121 8 84 29 195 141 290 110 0 272 93 142 134 140 32 232 99 162 199 297 287 212 29 182 53 61 98 116 282 75 245 230 165 22 4 179 89 274 231 46 299 248 208 200 285 221 50 221 199 294 241 195 138 22 204 113 100 132 276 158 146 238 178 100 94 131 157 ...

output:

0

result:

wrong answer 1st numbers differ - expected: '10', found: '0'