Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
pos = 0
visit = [0] * n
move = []
loop = []
while visit[pos] != 2:
    if visit[pos] == 0:
        move.append(pos)
    else:
        loop.append(pos)
    visit[pos] += 1
    pos = a[pos] - 1
if len(move) > k:
    print(move[k]+1)
else:
    print(loop[(k-(len(move)-len(loop)))%len(loop)]+1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
pos = 0
visit = [0] * n
move = []
loop = []
while visit[pos] != 2:
    if visit[pos] == 0:
        move.append(pos)
    else:
        loop.append(pos)
    visit[pos] += 1
    pos = a[pos] - 1
if len(move[k]) > k:
    print(move[k]+1)
else:
    print(loop[(k-(len(move)-len(loop)))%len(loop)]+1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
pos = 0
visit = [0] * n
move = []
loop = []
while visit[pos] != 2:
    if visit[pos] == 0:
        move.append(pos)
    else:
        loop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move[k]) > k:
    print(move[k]+1)
else:
    print(loop[(k-(len(move)-len(loop)))%len(loop)]+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
roop_find = deque([0])
i = 0
count = 0
while a[i]-1 not in roop_find:
    roop_find.append(a[i]-1)
    i = a[i] - 1
    count += 1
    if count == k:
        print(i + 1)
        break
    else:
        pass
if b < k:
    b = roop_find.index(a[i]-1)
    roop = list(roop_find)[b:count+1]

    k -= b
    e = k % (count+1-b)
    print(roop[e]+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
roop_find = deque([0])
i = 0
count = 0
while a[i]-1 not in roop_find:
    roop_find.append(a[i]-1)
    i = a[i] - 1
    count += 1
    if count == k:
        print(i + 1)
        break
    else:
        pass
if b <= k:
    b = roop_find.index(a[i]-1)
    roop = list(roop_find)[b:count+1]

    k -= b
    e = k % (count+1-b)
    print(roop[e]+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
roop_find = deque([0])
i = 0
count = 0
while a[i]-1 not in roop_find:
    roop_find.append(a[i]-1)
    i = a[i] - 1
    count += 1
    if count == k:
        print(i + 1)
        break
    else:
        pass
b = roop_find.index(a[i]-1)
roop = list(roop_find)[b:count+1]
if b < k:
    k -= b
    e = k % (count+1-b)
    print(roop[e]+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
roop_find = deque([0])
i = 0
count = 0
while a[i]-1 not in roop_find:
    roop_find.append(a[i]-1)
    i = a[i] - 1
    count += 1
    if count == k:
        ans = print(i + 1)
        break
    else:
        pass
b = roop_find.index(a[i]-1)
roop = list(roop_find)[b:count+1]
if b < k:
    k -= b
    e = k % (count+1-b)
    print(roop[e]+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
roop_find = deque([0])
i = 0
count = 0
while a[i]-1 not in roop_find:
    roop_find.append(a[i]-1)
    i = a[i] - 1
    count += 1
    if count == k:
        print(i+1)
        break
    else:
        pass
b = roop_find.index(a[i]-1)
roop = list(roop_find)[b:count+1]
k-=b
e = k % (count+1-b)
print(roop[e]+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,k = map(int,input().split())
a = list(map(int,input().split()))
roop_find = deque([0])
i = 0
count = 0
while a[i]-1 not in roop_find:
    roop_find.append(a[i]-1)
    i = a[i] - 1
    count += 1
b = roop_find.index(a[i]-1)
roop = list(roop_find)[b:count+1]

if k < b:
    print(roop_f[k]+1)
else:
    k-=b
    e = k % len(roop)
    print(roop[e]+1)