problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02684
u271469978
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import numpy as np\nN, M, X = map(int, input().split())\nA = []\nC = []\nfor _ in range(N):\n c, *a = map(int, input().split())\n C.append(c)\n A.append(a)\nA = np.array(A,dtype=int)\nans = 10 ** 7\nfor bit in range(2 ** N):\n B = np.zeros(M, dtype=int)\n cost = 0\n for i in range(N):\n if bi...
['Runtime Error', 'Accepted']
['s054148308', 's054861567']
[27064.0, 38916.0]
[119.0, 211.0]
[449, 635]
p02684
u279266699
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = list(map(lambda x: int(x) - 1, input().split()))\nvisited = [-1 for _ in range(n)]\nvisited[0] = 0\nl = [0]\nfor i in range(k):\n nex = a[l[i]]\n if visited[nex] != -1:\n res = visited[nex]\n cyc = i + 1 - visited[nex]\n break\n else:\n l += [...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s320513985', 's618678321', 's641836118', 's141780643']
[8988.0, 8996.0, 9048.0, 32388.0]
[22.0, 25.0, 23.0, 178.0]
[424, 402, 424, 423]
p02684
u288430479
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int,input().split())\nk += 1\nl1 = list(map(int,input().split()))\nl = list(i-1 for i in l1)\nbit = list(0 for i in range(n))\nbit[0] =1\nmi = [0]\nm = l[0]\ner = 0\nwhile er ==0:\n if bit[m]==1:\n a = mi.index(m)\n r = mi[a:]\n er =1\n else:\n bit[m] = 1\n mi.append(m)\n m = l[m]\n # p...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s021126730', 's790996306', 's172277828']
[32388.0, 34676.0, 32388.0]
[178.0, 215.0, 174.0]
[424, 419, 420]
p02684
u291028869
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int,input().split())\n\nA = list(map(int,input().split()))\nt = 0\nc = 0\nans = [0] * n\nL = []\nfor _ in range(k):\n if ans[t] == 1:\n t += k%c\n t = L[t]\n break\n else:\n ans[t] = 1\n L.append(t)\n print(L)\n t = A[t]-1\n c += 1\n\nprint(t+1)'...
['Runtime Error', 'Accepted']
['s776444833', 's750062418']
[147524.0, 32376.0]
[2678.0, 152.0]
[298, 340]
p02684
u291766461
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = map(int, input().split())\nA = list(map(int, input().split()))\nX = [1]\npos = 0\nfor i in range(2 * N):\n X.append(A[pos])\n pos = A[pos] - 1\nprint(X)\n\ns = set()\nloop = len(X)\nfor i, x in enumerate(X):\n if x in s:\n loop = i\n break\n else:\n s.add(x)\n#print(loop)\nx, y...
['Wrong Answer', 'Accepted']
['s106675875', 's942776650']
[36988.0, 32356.0]
[278.0, 164.0]
[533, 282]
p02684
u294385082
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nd = {}\nfor i in range(1, n + 1):\n d[i] = a[i - 1]\n\ndid = set(1)\nroute = [1]\n\nnow = 1\nfor i in range(k):\n now = d[now]\n route.append(now)\n if now in did:\n break\n did.add(now)\n\nif k < 10 ** 6:\n now = 1\n ...
['Runtime Error', 'Accepted']
['s541582728', 's869537738']
[40096.0, 49240.0]
[108.0, 270.0]
[571, 573]
p02684
u297651868
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k= list(map(int, input().split()))\nli= list(map(int, input().split()))\nd = [0 for i in range(n)]\nc=[1]\nnex=1\nfirst=0\nflag=0\nfor i in range(k):\n nex=li[nex-1]\n if d[nex]:\n first=c.index(nex)\n flag=1\n break\n d[nex-1]=1\n c.append(nex)\nif flag:\n k-=first\n k%=len(c...
['Runtime Error', 'Accepted']
['s507977256', 's887012685']
[92796.0, 32220.0]
[2209.0, 137.0]
[353, 355]
p02684
u300579805
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int, input().split())\na=list(map(int,list(input().split())))\n\nexist = [a[0]]\nex = {}\n\ncnt = 1\nwhile(True):\n if a[exist[-1]-1] in ex:\n idx = exist.index(a[exist[-1]-1])\n exist.append(a[exist[-1]-1])\n break\n exist.append(a[exist[-1]-1])\n ex[a[exist[-1]-1]] = 0\n \...
['Runtime Error', 'Accepted']
['s584157928', 's782070807']
[31208.0, 31508.0]
[64.0, 178.0]
[458, 525]
p02684
u305349402
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = list(map(int,input().split()))\nmove_list = list(map(int,input().split()))\n \n \ntest = 1\nfind_f = {}\nfor i in range(N):\n find_f[i+1]=[]\nt = K\n \nfind_f[1].append(0)\nfor i in range(K):\n test = move_list[test-1]\n find_f[test].append(i+1)\n if len(find_f[test]) == 2 and find_f[test][1]-find_f[test]...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s594628442', 's950297695', 's081096926']
[156140.0, 151888.0, 57468.0]
[2210.0, 2209.0, 332.0]
[527, 533, 511]
p02684
u307516601
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ninit = [1]\nwhile True:\n nxt = a[init[-1]-1]\n if nxt in init:\n idx_nxt = init[nxt]\n loop = init[idx_nxt:]\n init = init[:idx_nxt]\n break\n else:\n init.append(nxt)\n\nidx = (k-len(init))%len(...
['Runtime Error', 'Accepted']
['s792495779', 's162179502']
[32380.0, 32364.0]
[2206.0, 160.0]
[326, 472]
p02684
u307592354
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['def resolve():\n N,K = map(int,input().split())\n A = [int(i)-1 for i in input().split()]\n visited =[False]*N\n steps = [K for i in range(N)]\n\n current = 0\n while True:\n\n if K == 0:\n\t\t\tprint(current+1)\n return\n if not visited[current]:\n visited[curren...
['Runtime Error', 'Accepted']
['s683994776', 's688759288']
[9044.0, 32328.0]
[24.0, 138.0]
[588, 597]
p02684
u307622233
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = [int(i) for i in input().split()]\n\nlst = []\nvisit_now = 1\n\nwhile True:\n if visit_list[visit_now - 1] == 1:\n break\n visit_list[visit_now - 1] = 1\n lst.append(visit_now)\n visit_now = a[visit_now - 1]\n\n\nstart = lst.index(visit_now)\nloop_num = n - sta...
['Runtime Error', 'Runtime Error', 'Accepted']
['s029201121', 's417218492', 's733774240']
[32352.0, 32256.0, 32276.0]
[74.0, 67.0, 179.0]
[406, 433, 446]
p02684
u312158169
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,m = map(int,input().split())\na = [int(x) for x in input().split()]\n\nans1 = [1]\ntemp = 0\ncount = 0\nwhile(True):\n ans1 += [a[temp]]\n temp = a[temp]-1\n if len(ans1) != len(set(ans1)):\n break\n count += 1\n if count == m:\n print(ans1[len(ans1)-1])\n exit()\n\n\nnum1 = an...
['Wrong Answer', 'Accepted']
['s976101998', 's652503583']
[32280.0, 32332.0]
[2206.0, 179.0]
[403, 423]
p02684
u314089899
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K = map(int, input().split())\nA_list = [0] + [int(e) for e in input().split()]\n\nused_tele = 0\nrepeating_flag = False\nmoving_dict = dict() \nmoving_dict[1]= 0\nnow_town = 1\n\nwhile used_tele<K:\n next_town = A_list[now_town]\n used_tele += 1\n print(used_tele,":",now_town,"→",next_town)\n \n if ...
['Wrong Answer', 'Accepted']
['s282993024', 's376806162']
[31988.0, 33372.0]
[349.0, 149.0]
[993, 994]
p02684
u316231243
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['from collections import defaultdict\nn,k=map(int,input().split())\nl=list(map(int,input().split()))\nd=defaultdict(int)\nfor i in range(n):\n d[i+1]=l[i]\nvisited=set()\nl=[]\ni=1\nwhile True:\n l.append(i)\n if i not in visited:\n visited.add(i)\n else:\n break\n i=d[i]\nfirst=l.index(l[...
['Wrong Answer', 'Accepted']
['s873410861', 's430418196']
[47520.0, 47652.0]
[223.0, 225.0]
[409, 404]
p02684
u319589470
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['#!/usr/bin/env python3\nimport bisect\nimport heapq\nimport itertools\nimport math\nimport numpy as np\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom math import gcd\nfrom operator import add, itemgetter, mul, xor\ndef cmb(n,r,mod):\n bunshi=1\n bu...
['Runtime Error', 'Runtime Error', 'Accepted']
['s623107782', 's730310528', 's039206868']
[50756.0, 8928.0, 50548.0]
[2207.0, 27.0, 239.0]
[1616, 1464, 1464]
p02684
u320511454
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=list(map(int,input().split()))\nA=list(map(int,input().split()))\nstart,i,j=1,0,0\nroot=[1]\n\nfor j in range(k):\n start=A[start-1]\n if start in root:\n i = start\n break\n root.append(start)\n \nif k <= len(root):\n print(root[k-1])\nelse:\n newroot=root[i-1:]\n print(newroot)\n ans=(k-len(root))...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s020405202', 's521688952', 's818683760', 's909293992']
[32376.0, 32380.0, 36896.0, 37044.0]
[2206.0, 2206.0, 158.0, 165.0]
[336, 332, 344, 339]
p02684
u321035578
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
["def main():\n n,k = map(int,input().split())\n a = list(map(int,input().split()))\n cnt = [-1] * n\n cnt[0] = 0\n ary = []\n now = 1\n ary.append(now)\n if k <= n:\n for i in range(1,k+1):\n now = a[now-1]\n if i == k:\n print(now)\n r...
['Runtime Error', 'Accepted']
['s794558281', 's758015210']
[32360.0, 33400.0]
[119.0, 123.0]
[636, 744]
p02684
u323045245
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int, input().split())\ntele = list(map(int, input().split()))\nmove = [-1]*n\nmove[0] = 0\nnow = 0\ncnt = 0\n\nwhile True:\n cnt += 1\n now = tele[now] - 1 \n\n if move[now] != -1:\n cycle = cnt - move[now]\n break\n move[now] = cnt\n\n\nif cnt-1 >= k:\n ans = 0\n for i in ra...
['Wrong Answer', 'Accepted']
['s746397298', 's270915892']
[32188.0, 32300.0]
[145.0, 129.0]
[712, 767]
p02684
u324090406
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = list(map(int, input().split()))\na_list = list(map(int, input().split()))\n\ndone_list = [1]\ncur_place = 1\nflag = True\nfor i in range(K):\n if a_list[cur_place-1] not in done_list:\n cur_place = a_list[cur_place-1]\n done_list.append(cur_place)\n else:\n period = len(done_list) - ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s052832524', 's754816503', 's156009834']
[32268.0, 32236.0, 32200.0]
[2206.0, 2206.0, 155.0]
[508, 508, 691]
p02684
u324197506
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\n\nroads = list(map(int, input().split()))\n\ncity = 1\nroute = []\ncnt = [0] * n\ncnt[0] += 1\nroute.append(0)\n\n\nwhile True:\n city = roads[city-1] \n cnt[city-1] += 1\n if cnt[city-1] == 2:\n st = route.index(city)\n length = len(route) - st\n break\...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s184586048', 's512410369', 's873592630']
[32380.0, 32380.0, 32396.0]
[175.0, 202.0, 202.0]
[501, 549, 489]
p02684
u328179275
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int,input().split())\na = input().split()\nb = [0]*n\nd = {}\nind = 1\nnum = 0\nloop = 1\nwhile num == k:\n if b[ind-1] == 0:\n b[ind-1] = -1\n d[ind] = num\n num += 1\n ind = int(a[ind-1])\n else:\n loop = num-d[ind]\n sup = d[ind]\n break\n\nif k-sup ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s748115035', 's952589312', 's632119820']
[24584.0, 51972.0, 40908.0]
[43.0, 255.0, 180.0]
[378, 351, 348]
p02684
u331226975
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nr = [0]*N\n\nnow = 0\nr[now]=1\nfor i in range(N):\n now = A[now]-1\n if r[now] == 0:\n r[now] = i+2\n else:\n x1 = r[now]\n x2 = i+1\n break\nprint(x1, x2)\nprint(r)\nroop_num = x2 - x1 + 1\nx = (K-x1+1) % roop_num\nprint(x)\nif ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s582535976', 's949206793', 's073508197']
[32300.0, 32376.0, 32296.0]
[143.0, 2206.0, 155.0]
[363, 255, 333]
p02684
u337626942
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k=map(int, input().split())\na=list(map(int, input().split()))\na.insert(0, 0)\n\nfor i in range(1, n+1):\n if a.count(i)>=1:\n s_index=i\n break\n\ncnt=0\nn_index=a[s_index]\nfor j in range(1, n+1):\n if n_index==s_index:\n cnt+=1\n break\n else:\n n_index=a[n_index]\n ...
['Wrong Answer', 'Accepted']
['s198839327', 's068063984']
[32376.0, 32380.0]
[138.0, 213.0]
[350, 326]
p02684
u340781749
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import sys\n\nn, k, *aaa = map(int, sys.stdin.buffer.read().split())\nshortest = [-1] * n\nv = 0\nd = 0\nwhile shortest[v] == -1:\n shortest[v] = d\n v = aaa[v] - 1\n d += 1\n if d == k:\n print(v + 1)\n exit()\n\nfirst = shortest[v]\nloop = d - first\nremaining = (k - first) % loop\nprint(v...
['Wrong Answer', 'Accepted']
['s869357582', 's967430804']
[27932.0, 27908.0]
[166.0, 1111.0]
[400, 184]
p02684
u342563578
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int,input().split())\na = list(map(int,input().split()))\np = a[0]\ns = a[0]\ng = []\nq = []\nfor i in range(n+1):\n g.append(p)\n p = a[p-1]\nfor i in range(len(g)):\n if g[i] == g[i] + mod\ng.reverse()\nfor i in range(n):\n if g[0] == g[i+1]:\n mod = i+1\n break\ng.reverse()\nfor...
['Runtime Error', 'Accepted']
['s590727477', 's632774113']
[9052.0, 32272.0]
[23.0, 180.0]
[535, 464]
p02684
u344030307
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int, input().split())\na = list(map(int, input().split()))\n\ntele = [1]\nwent = set(tele)\nnow = 1\ncnt = 0\nflag = True\n\nfor i in range(k):\n now = a[now-1]\n if now in went:\n tele = tele[tele.index(now):]\n cnt = len(tele)\n flag = False\n break\n tele.append(now)\n went.add(now)\n\nif...
['Wrong Answer', 'Accepted']
['s003785869', 's899866661']
[32264.0, 32356.0]
[167.0, 161.0]
[386, 397]
p02684
u347600233
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K,*A=map(int,open(0).read().split())\na=1\nwhile K>0:\n if K&1:\n a=A[a-1]\n A=[A[A[i]-1] for i in range(N)]\n K>>=1\nprint(a)', 'n, k = map(int, input().split())\na = [int(i) for i in input().split()]\nordi = [0, ]\nfor i in range(n):\n if a[ordi[-1]] - 1 not in ordi:\n ordi.append(a[...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s211169260', 's971337676', 's039832395']
[31768.0, 32196.0, 32332.0]
[1260.0, 2206.0, 1162.0]
[141, 353, 181]
p02684
u349444371
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\nA=list(map(int,input().split()))\np=1\nl=[0]*n\n#l[0]+=1\nif k<=100000:\n for i in range(k):\n p=A[p-1]\n l[p-1]+=1\n print(p)\n exit()\nelse:\n for i in range(100001):\n p=A[p-1]\n l[p-1]+=1\n #print(p)\n if l[p-1]==2:\n x...
['Runtime Error', 'Accepted']
['s228617965', 's964430709']
[9100.0, 32380.0]
[25.0, 150.0]
[626, 688]
p02684
u362255558
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
["N, K = [ int(i) for i in input().strip().split(' ') ]\nA = [ int(i) for i in input().strip().split(' ') ]\n\ncurrent = 1\nN_counter = [0] * N \nN_counter_idx = [0] * N \nN_counter[current-1] += 1\n\nk_reserved = -1\nfor i in range(1, N+1):\n current = A[current-1]\n N_counter[current-1] += 1\n if i == K:\n ...
['Wrong Answer', 'Accepted']
['s500078997', 's302075047']
[32332.0, 32340.0]
[191.0, 185.0]
[818, 884]
p02684
u364027015
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import numpy as np\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\ndef B(i):\n if i==0:\n return 1\n return A[B(i-1)-1]\nC=[1]\nfor i in range(1,N+1):\n if C.count(B(i))==0:\n C.append(B(i))\n else:\n l=C.index(B(i))+1\n break\nif K+1<=l:\n print(C[K])\nelse:\n print(C[l-1])\nprint(...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s238523207', 's461486924', 's537613504', 's958107455']
[51044.0, 50936.0, 51104.0, 50940.0]
[305.0, 154.0, 2207.0, 284.0]
[302, 283, 364, 295]
p02684
u367965715
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = list(map(lambda x: int(x)-1, input().split()))\n\nvisited = [1] + [0]*(n-1)\nidx = [0] + [-1]*(n-1)\nroute = [0]\nwhile True:\n now = a[route[-1]]\n if visited[now]:\n break\n visited[now] = 1\n idx[now] = len(route)\n route.append(now)\n\nborder = idx[a[rou...
['Wrong Answer', 'Accepted']
['s995029106', 's562312759']
[32384.0, 32308.0]
[214.0, 191.0]
[468, 452]
p02684
u369133448
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\na=list(map(int,input().split()))\ndic={}\nwk=1\nstart=0\nfor i in range(1,n+1):\n wk=a[wk-1]\n if wk in dic:\n start=dic[wk]\n break\n dic[wk]=i\nend=len(dic)\nloopcnt=end-start+1\nkeys=list(dic.keys())\nif k<start:\n print(keys[k-1])\nelse:\n chk=(k-start+1)%loopcntac\n if c...
['Runtime Error', 'Accepted']
['s027324205', 's124669717']
[38704.0, 38696.0]
[147.0, 147.0]
[354, 352]
p02684
u370721525
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nnum = 1\nl = []\nl.append(num)\ni = 0\nwhile i < K-1:\n num = A[num-1]\n if num not in l:\n l.append(num)\n i += 1\n else:\n i = K - (K-1-i) % (i+1-(l.index(num)))\n break;\n \nwhile i < K-1:\n num = A[num-1]\n i += 1\n \npr...
['Wrong Answer', 'Accepted']
['s285821724', 's145692762']
[32364.0, 32376.0]
[2206.0, 166.0]
[306, 370]
p02684
u372320597
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K = map(int, input().split())\nA = list(map(int, input().split()))\np = 1\np_hist = []\nwhile p not in p_hist:\n p_hist.append(p)\n p = A[p-1]\nend_loop = p_hist[-1]', 'N,K = map(int, input().split())\nA = list(map(int, input().split()))', 'N,K = map(int, input().split())\nA = list(map(int, input().split()))\...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s610134459', 's695086999', 's348863543']
[32172.0, 32376.0, 36884.0]
[2206.0, 66.0, 204.0]
[166, 67, 518]
p02684
u373047809
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k,*a=map(int,open(0).read().split());a=[0]+a;p=1\nwhile k:p=k%2*p and a[p];a=[a[b]for b in a];k//=2\nprint(p)', '_,k,*a=map(int,open(0).read().split());a=[0]+a;p=1\nwhile k:p=~-k%2*p or a[p];a=[a[b]for b in a];k//=2\nprint(p)']
['Wrong Answer', 'Accepted']
['s117698838', 's056778374']
[31812.0, 31804.0]
[1374.0, 1169.0]
[109, 110]
p02684
u374935093
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['max = int(data[1])\nlimit = max\ntimes = 0\npos = 1\nexperience = [1]\nwhile max > 0:\n pos = telepo[pos - 1]\n max -= 1\n times += 1\n #print(pos)\n if pos in experience:\n length = len(experience) - experience.index(pos)\n max = max % length\n if max == 0:\n break\n ...
['Runtime Error', 'Accepted']
['s908561332', 's883784758']
[9084.0, 44412.0]
[22.0, 213.0]
[476, 632]
p02684
u375172966
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = list(map(int, input().split()))\nvisited = [0]\nfor _ in range(n):\n now = a[visited[-1]]-1\n visited.append(now)\n\nif k <= n:\n print(visited[k]+1)\nelse:\n p = visited.index(visited[-1])\n loop = visited[::-1][1:].index(visited[-1])+1\n x = (k-p-1)%loop\n ...
['Wrong Answer', 'Accepted']
['s873045537', 's708735685']
[32328.0, 32332.0]
[133.0, 130.0]
[351, 328]
p02684
u379601169
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
["from collections import deque\n\nN, M = map(int, input().split())\nAB = [map(int, input().split()) for _ in range(M)]\n\nlinks = [[] for _ in range(N + 1)]\nfor a, b in AB:\n links[a].append(b)\n links[b].append(a)\n\nresult = [-1] * (N + 1)\nq = deque([1])\nwhile q:\n i = q.popleft()\n for j in links[i]:...
['Runtime Error', 'Accepted']
['s329432774', 's914266343']
[25912.0, 34248.0]
[42.0, 230.0]
[440, 714]
p02684
u379716238
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nc = [0]*N\ncc = [0]\nc[0] = 1\ni = 0\nwhile True:\n c[A[i]-1] += 1 \n cc.append(A[i]-1)\n if c[A[i]-1] > 1:\n memo = A[i]-1\n break\n i = A[i] - 1 \n \nused = [i for i in range(N) if c[i] > 0]\n\npos = [i for i in range(len(cc)) i...
['Wrong Answer', 'Accepted']
['s526469457', 's520432912']
[33964.0, 35624.0]
[238.0, 229.0]
[560, 511]
p02684
u394950523
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nl = [1, A[0]]\na = A[0] - 1\nfor _ in range(0, N):\n if A[a] not in l:\n l.append(A[a])\n a = A[a] - 1\n else:\n a = A[a]\n break\nn = len(l)\nprint(l)\nb = 0\nfor i in range(n):\n if l[i] == a:\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s688074543', 's711876245', 's076530863']
[32344.0, 32384.0, 32456.0]
[2206.0, 2206.0, 173.0]
[418, 396, 412]
p02684
u396210538
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['from sys import stdin\nimport sys\n\nN, K = [int(x) for x in stdin.readline().rstrip().split()]\nA = list(map(int, input().split()))\nB = [i for i in range(1, N+1)]\nd = dict(zip(B, A))\nt = [0 for i in range(N)]\nd1 = dict(zip(B, t))\ntemp = 1\ncnt = 0\nans = []\nfor i in range(K+1):\n d1[d[temp]] = d1.get(d[temp...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s258825974', 's307840550', 's860855732', 's122463617']
[56796.0, 56900.0, 56888.0, 56816.0]
[470.0, 493.0, 470.0, 449.0]
[678, 676, 673, 677]
p02684
u396858476
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
["N, K = map(int, input().split())\nA = input().split()\nA_MAP = {}\nfor i in range(N):\n A_MAP[str(i+1)] = A[i]\n\nprint(A_MAP)\nroute_hash = {'1': 0}\ncurrent_pos = '1'\nnext_pos = ''\ncounter = 0\nwhile counter <= K:\n next_pos = A_MAP[current_pos]\n counter+=1\n if next_pos in route_hash:\n break...
['Wrong Answer', 'Accepted']
['s351518094', 's556083035']
[64296.0, 61492.0]
[333.0, 265.0]
[827, 775]
p02684
u404629709
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\nnum=[0 for i in range(n)]\nfirst=[0 for i in range(n)]\nfirst[0]=1\na=list(map(int,input().split()))\nfor i in range(n):\n a[i]-=1\nnum[0]=1\nloop=0\ns=0\nfor i in range(n):\n if num[a[s]]==0:\n num[a[s]]+=1\n first[a[s]]=i\n if num[a[s]]==2:\n loop1=loop\n break\n s=a[s]...
['Runtime Error', 'Accepted']
['s784943994', 's103083244']
[35488.0, 32364.0]
[203.0, 197.0]
[399, 485]
p02684
u405660020
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k_in=map(int, input().split())\na_l=list(map(int, input().split()))\n\ndef f(s):\n a = s\n b = s\n i=1\n while True:\n a = a_l[a-1]\n a = a_l[a-1]\n b = a_l[b-1]\n if a == b:\n break\n i+=1\n\n j=1\n a = a_l[0]\n while True:\n a = a_l[a-1]\n...
['Runtime Error', 'Accepted']
['s422841931', 's455341622']
[33364.0, 32296.0]
[327.0, 164.0]
[716, 374]
p02684
u408071652
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int,input().split())\na = list(map(int,input().split()))\na.insert(0,0)\nprint(a)\n\ntown =1\nvisited = [0] * (n+1)\n\nfor i in range(1,k+1):\n town = a[town]\n if visited[town] !=0:\n rest =(k - visited[town]) % (i -visited[town])\n goal =visited.index(visited[town]+rest)\n brea...
['Runtime Error', 'Accepted']
['s316349217', 's668640732']
[32296.0, 32336.0]
[155.0, 98.0]
[347, 542]
p02684
u409542115
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\nA=list(map(int,input().split()))\nA=[0]+A\nB=[]\nC=[0]+[-1]*n\nnow_city=1\nseen=set()\n\n\nfor i in range(1,len(A)):\n print("Baah")\n', 'n,k=map(int,input().split())\nA=list(map(int,input().split()))\nA=[0]+A\nB=[]\nC=[0]+[-1]*n\nnow_city=1\nseen=set()\n\n\nfor i in range(1,len(A)):\...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s013765017', 's250367745', 's314422702', 's348930670', 's613071852', 's689337113', 's728627634', 's821845993', 's828004579', 's929722753', 's384005857']
[32232.0, 32368.0, 9048.0, 32364.0, 32380.0, 32348.0, 32296.0, 32376.0, 32368.0, 32280.0, 32344.0]
[125.0, 70.0, 24.0, 130.0, 123.0, 118.0, 144.0, 2206.0, 2206.0, 137.0, 226.0]
[184, 295, 530, 254, 333, 191, 528, 351, 369, 227, 1103]
p02684
u411478442
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['def check(pair,m,x):\n l = len(pair)\n sum = 0\n \n for i in range(1,m):\n p = 0\n for j in range(l):\n p += pair[j][i]\n \n if(p < x):\n return -1\n \n for e in pair:\n sum += e[0]\n return sum\n \nn,m,x = (int(x) for x in input().split())\na = []\nfor i in range(n):\n a.appen...
['Runtime Error', 'Accepted']
['s644291207', 's858204171']
[9268.0, 32332.0]
[22.0, 163.0]
[593, 400]
p02684
u413632062
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\na=[int(i)-1 for i in input().split()]\np=0\nvisited=[0]*n\nfirst=[]\nroop=[]\nwhile visited[p]!=2:\n if visited[p]==0:\n first.append(p)\n else:\n roop.append(p)\n visited[p]+=1\n p=a[p]\nprint(first,roop)\nif len(first)>k:\n print(first[k]+1)\nelse:\n pri...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s286760332', 's404816797', 's455510655', 's890258435']
[32204.0, 88536.0, 87792.0, 32332.0]
[306.0, 2208.0, 2208.0, 231.0]
[644, 620, 622, 626]
p02684
u416011173
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['# -*- coding: utf-8 -*-\n\nimport math\n\n\ndef get_input() -> tuple:\n \n N, K = list(map(int, input().split()))\n A = list(map(int, input().split()))\n\n return N, K, A\n\n\ndef main(N: int, K: int, A: list) -> None:\n \n \n to = [A]\n for i in range(math.ceil(math.log2(K))):\n to_i =...
['Runtime Error', 'Accepted']
['s770442350', 's698606243']
[31192.0, 113488.0]
[246.0, 1919.0]
[1053, 956]
p02684
u419354839
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K = map(int,input().split())\nA = list(map(lambda x: int(x) - 1, input().split()))\nP = [-1] * N \ncur = 0\nP[cur] = 0\nroute = [1]\n\nfor step in range(K):\n cur = A[cur]\n route.append(cur + 1)\n if P[cur] >= 0:\n l_start = P[cur]\n l_end = step + 1\n l_len = l_end - l_start\n break\n else:\n P...
['Wrong Answer', 'Accepted']
['s210007365', 's816781921']
[32380.0, 32268.0]
[212.0, 139.0]
[425, 399]
p02684
u423665486
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import sys\nfrom io import StringIO\nimport unittest\n\nsys.setrecursionlimit(100**5)\n\ndef search(u, n, g, disc, k):\n if disc[u] != None:\n circles = n - disc[u]\n v = (k - disc[u]) % circles\n ans = u\n for i in range(v):\n ans = g[ans]\n return ans + 1\n disc[u...
['Runtime Error', 'Runtime Error', 'Accepted']
['s311291510', 's773073450', 's305671479']
[16244.0, 16272.0, 32360.0]
[67.0, 68.0, 131.0]
[536, 359, 371]
p02684
u425762225
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = map(int,input().split())\na = [0] + list(map(int,input().split()))\n\njourney = [1]\n\nfor i in range(N):\n nxt = a[journey[-1]]\n journey.append(nxt)\n\nif K < N:\n print(journey[K])\n exit()\n\nloop_start = N-1\nloop_end = N\n\nfinished = False\nfor i in range(N):\n for j in range(i,N+1):\n ...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s201731122', 's401782966', 's494970321', 's560623440', 's487685760']
[32376.0, 32412.0, 32416.0, 32376.0, 32232.0]
[107.0, 2206.0, 2206.0, 70.0, 258.0]
[541, 566, 577, 92, 408]
p02684
u426175055
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K = map(int,input().split())\nA = list(map(int,input().split()))\n\ntown = [0 for i in range(N)]\n\ndef next(A,now):\n return(A[now-1])\n\nnow = 1\ni = 0\nwhile True:\n if town[now-1] != 0:\n roop_start = town[now-1]\n roop_end = i\n break\n town[now-1] = i+1\n now = next(A,now)\n ...
['Wrong Answer', 'Accepted']
['s083754699', 's540457942']
[32380.0, 32368.0]
[227.0, 204.0]
[474, 462]
p02684
u426572476
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import sys\nimport heapq\nimport re\nfrom itertools import permutations\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, deque\nfrom math import factorial, sqrt, ceil, gcd\nfrom functools import lru_cache, reduce\nINF = 1 << 60\nMOD = 1000000007\nsys.setrecursionlimit(10 ** 7)\n\n# Unio...
['Wrong Answer', 'Accepted']
['s155828477', 's634545592']
[34020.0, 34036.0]
[205.0, 227.0]
[4291, 4589]
p02684
u426649993
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['root = list()\n\n\ndef dfs(A, num, N):\n if A[num] in root:\n return root.index(A[num])\n else:\n root.append(A[num])\n return dfs(A, A[num]-1, N)\n\n\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n\n start = dfs(A, 0, N)\n\n if K <= len(r...
['Runtime Error', 'Accepted']
['s783303583', 's955626891']
[32372.0, 193324.0]
[78.0, 322.0]
[457, 597]
p02684
u428199834
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K=map(int,input().split())\nA=list(map(int,input().split()))\ns=1\nB=[1]\nfor i in range(K):\n s=A[s-1]\n if s in B:\n u=B.index(s)\n u_=len(B)-u\n t=(K-u+1)%u_\n if t>=1 and u>=1:\n print(B[u+t-1])\n break\n elif u==0:\n t=(K+1)%u_\n print(B[t-1])\n break\n else:\n ...
['Wrong Answer', 'Accepted']
['s157415658', 's746474662']
[32380.0, 32176.0]
[2206.0, 134.0]
[382, 404]
p02684
u430726059
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int, input().split())\na=list(map(int, input().split()))\nalist=[]\ni=1\nwhile a[i-1] not in alist:\n i=a[i-1]\n alist.append(i)\nloop1=alist.index(a[i-1])\nif k<loop1+1:\n print(alist[k-1])\nelse:\n lenloop=len(alist)-loop1\n print(alist[((k-loop1-1)%lenroop)+loop1])', 'n,k=map(int, input().split())\na=...
['Runtime Error', 'Accepted']
['s474784240', 's922383655']
[32216.0, 32372.0]
[2206.0, 167.0]
[269, 287]
p02684
u431658223
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import sys\ninput = lambda : sys.stdin.readline().strip()\nn,k = map(int,input().split())\nk = k%n\na = list(map(int,input().split()))\ncur = 0\nwhile k:\n k-=1\n cur = a[cur]-1\nprint(cur+1)', 'import sys\ninput = lambda : sys.stdin.readline().strip()\nn,k = map(int,input().split())\na = list(map(int,input().s...
['Wrong Answer', 'Accepted']
['s731561278', 's438498104']
[32372.0, 35724.0]
[113.0, 251.0]
[188, 671]
p02684
u432251613
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['def main():\n \n N,K = map(int, input().split())\n A = list(map(int, input().split()))\n\n \n \n \n now = 0\n history = [0]\n i = 0\n while i<K:\n \n print(i)\n now = A[now]-1\n \n if now not in history:\n history.append(now)\n i+=...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s773907470', 's799745825', 's800363437']
[50108.0, 9012.0, 31888.0]
[2277.0, 24.0, 122.0]
[869, 904, 951]
p02684
u433371341
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = [int(n) for n in input().split()]\nA = [int(n) for n in input().split()]\n\ndest = []\n\ncurrent = 0\nnext_dest = A[current]\ncount = 0\nseen = set()\n\nwhile not next_dest in seen:\n dest.append(next_dest)\n current = next_dest-1\n next_dest = A[current]\n seen.add(current)\n\ndest.append(next_des...
['Wrong Answer', 'Accepted']
['s559532551', 's634541973']
[96940.0, 40008.0]
[2208.0, 167.0]
[357, 490]
p02684
u434609232
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import sys\n\nN, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nA = [0] + A\ntown = 1\nvisited = [0]*(N+1)\n\nfor i in range(1, K+1):\n town = A[town]\n if visited[town] == 0:\n visited[town] = i\n else:\n loop = i - visited[town]\n town = (K - visited[town]) %...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s474180109', 's741728173', 's078899674']
[32328.0, 32376.0, 32312.0]
[166.0, 137.0, 129.0]
[337, 351, 393]
p02684
u440129511
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\na=list(map(int,input().split()))\nl=[]*n\nfor i in range(n):\n b=[0,0]\n b[0]+=i+1\n b[1]+=a[i]\n l.append(b)\nc=0\nne=0\nl1=[0]*n\nwhile True:\n if c==k:\n print(l[ne][1])\n exit()\n ne+=-ne+l[ne][1]-1\n c+=1\n if l1[ne]==0:l1[ne]+=1\n else:\n ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s783097508', 's964142921', 's080996343']
[50072.0, 50088.0, 32308.0]
[329.0, 409.0, 180.0]
[624, 603, 701]
p02684
u443872523
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nl = [1]\nind = 0\nval = 0\nfor i in range(n):\n val = a[ind]\n l.append(val)\n ind = val - 1\n\nprint("l:", l)\ncnt = 1\nrepeat =[]\nrepeat.append(l.pop())\nz = 0\n\nfor j in range(n - 1, -1, -1):\n z = l.pop()\n if z == repeat[0]...
['Wrong Answer', 'Accepted']
['s973600241', 's594739941']
[32404.0, 32424.0]
[207.0, 175.0]
[459, 494]
p02684
u445624660
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['\nn, k = map(int, input().split())\na = list(map(lambda x: int(x) - 1, input().split()))\ncount_arr = [0] * n\ncount = 0\n\nnow = 0\nloop_length = -1\nwhile True:\n if count == k:\n print(a[now] + 1)\n exit()\n if count_arr[now] != 0:\n loop_length = count - count_arr[now] + 1\n brea...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s875588894', 's927951547', 's289726512']
[33336.0, 32264.0, 32308.0]
[167.0, 149.0, 147.0]
[778, 1038, 733]
p02684
u446808186
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K=map(int,(input().split()))\nTO=list(map(int,input().split()))\n\nvisit_flag=[[0]*2 for i in [1]*N]\nvisit_count=0\nfirst_visit=0\nlast_visit=0\nnext_town=1\nvisit_flag[0][0]=1\nvisit_flag[0][1]=0\n\nfor i in range(K):\n visit_count+=1\n next_town = TO[next_town-1]\n if visit_flag[next_town-1][0]==0:\n ...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s158762166', 's225774514', 's608026707', 's787256985', 's110996754']
[9052.0, 40776.0, 40668.0, 40664.0, 40876.0]
[25.0, 298.0, 301.0, 283.0, 312.0]
[832, 734, 736, 736, 826]
p02684
u447899880
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\na=list(map(int,input().split()))\n\nans=0\nnow=1\ni=1\nresult=[1]\nwhile i<=k:\n now=a[now]\n if now in result:\n x=result.index(now)\n length=i-1-x\n ans=result[(k-x)%length+x]\n result.append(now)\n i+=1\n \nif ans!=0:\n print(ans)\nelse:\n pri...
['Runtime Error', 'Runtime Error', 'Accepted']
['s210961376', 's288347931', 's153942460']
[35420.0, 34508.0, 32300.0]
[2206.0, 2206.0, 141.0]
[313, 315, 338]
p02684
u449580152
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\nA = list(map(int, input().split()))\ndef f(x):\n return A[x-1]\nc = 1, P = [1]\n\nfor i in range(k):\n c = f(c)\n P.append(c)\n if c in P:\n roop_start = P.find(c)\n roop_num = i + 1- roop_start\n break\na = (k - roop_start) % roop_num\nfor i in ran...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s165977471', 's192229849', 's415729900', 's603060250', 's607505989', 's682208192', 's731819277', 's866114848', 's231802504']
[9140.0, 46964.0, 32352.0, 113504.0, 117612.0, 32376.0, 116636.0, 32236.0, 32364.0]
[23.0, 2223.0, 69.0, 2210.0, 2208.0, 68.0, 2209.0, 2206.0, 1251.0]
[359, 352, 359, 355, 361, 360, 290, 365, 188]
p02684
u455957433
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['def main():\n \n IN = [int(_) for _ in input().split()]\n A = [int(_) for _ in input().split()]\n N = IN[0]\n K = IN[1]\n\n loop = []\n target = 1\n mark = [False] * N\n print(mark)\n mark[0] = True\n while True:\n target = A[target -1]\n loop.append(target)\n if ...
['Wrong Answer', 'Accepted']
['s658052158', 's319955837']
[32256.0, 32352.0]
[140.0, 125.0]
[604, 1098]
p02684
u459798349
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\nA=[int(i) for i in input().split()]\n\nwent={i:0 for i in range(1,n+1)}\n\nnow=1\ncnt=1\nfor i in range(n+1):\n if went[now]>0:\n t=cnt\n s=went[now]\n break\n else:\n went[now]=cnt\n now=A[now-1]\n cnt+=1\n\nval=((k-t)%(t-s+1)-1)%(t-s+1)+s...
['Wrong Answer', 'Accepted']
['s677450652', 's227140895']
[40460.0, 40592.0]
[262.0, 290.0]
[374, 414]
p02684
u460229551
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=list(map(int,input().split()))\nAs=list(map(int,input().split()))\nroot=[1]\ncount=[0]*n\ncount[0]+=1\n\nfor i in range(k):\n if count[root[-1]-1]!=0:\n break\n else:\n root.append(As[root[-1]-1])\n count[As[root[-1]-1]-1]+=1\nprint(root[k%len(root)])', 'n,k=list(map(int,input().split()...
['Wrong Answer', 'Accepted']
['s319794088', 's257375954']
[32376.0, 32376.0]
[68.0, 163.0]
[270, 387]
p02684
u464205401
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=list(map(int,input().split()))\na=[0]+ list(map(int,input().split()))\n\nvisited=[1]\n\nfor i in range(n):\n next=a[visited[-1]]\n visited.append(next)\n \nloop_end=n\nloop_start=n-1\nwhile visited[loop_start]!=visited[loop_end]:\n loop_start-=1\nperiod=loop_end-loop_start\n#print(visited) \n#print("p:",perio...
['Runtime Error', 'Accepted']
['s932768421', 's227737584']
[32376.0, 32364.0]
[162.0, 179.0]
[415, 428]
p02684
u465900169
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = []\ni = 0\nB.append(1)\nfor n in range(N):\n B.append(A[i])\n i = A[i]-1\nif K>N:\n start = 0\n num = 0\n for j in range(len(B)):\n if B[len(B)-1] == B[j]:\n start = j\n break\n for j in range(1,len(B)-start):\n if B[star...
['Wrong Answer', 'Accepted']
['s282364812', 's663270287']
[32260.0, 32380.0]
[176.0, 179.0]
[421, 399]
p02684
u466143662
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nidx = a[0]\nhist = [1]\nflag = 0\nfor i, _ in enumerate(range(k), start=1):\n if idx in hist:\n hist.append(idx)\n flag = 1\n break\n hist.append(idx)\n idx = a[idx-1]\n \nif flag:\n l_start2, l_end2 = hist.in...
['Runtime Error', 'Accepted']
['s073002843', 's779279566']
[32312.0, 32328.0]
[2206.0, 153.0]
[414, 498]
p02684
u469254913
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nfrom numba import njit\n\n\n@njit\ndef make_my_route(route,A,N):\n pre = 1\n for i in range(N):\n now = A[pre-1]\n temp = np.sum(route == now)\n if temp == 1:\n ...
['Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s436778737', 's719649963', 's949790191', 's040319753']
[119696.0, 119764.0, 119636.0, 30852.0]
[2210.0, 2210.0, 2209.0, 120.0]
[896, 911, 853, 557]
p02684
u471503862
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = list(map(int,input().split()))\ntimestamp = [0]*n\nposition = 1\nperiod = 0\nstart=0\nfor i in range(n):\n if timestamp[position-1] != 0:\n start = timestamp[position-1]\n period = i-timestamp[position-1]\n break\n timestamp[position-1] =i\n position = a[position-1]\n...
['Runtime Error', 'Accepted']
['s952190476', 's921348355']
[32376.0, 32384.0]
[174.0, 165.0]
[537, 519]
p02684
u475402977
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K=(int(x) for x in input().split())\nA=list(map(int, input().split()))\nif K<=N:\n s=1\n for i in range(K):\n s=A[s-1]\n print(s)\nelse:\n s=1\n S={1}\n iloop=1\n while A[s-1] not in S:\n S.add(A[s-1])\n s=A[s-1]\n iloop=iloop+1\n p=s\n loop=1\n while A[s-1]...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s221233739', 's860111431', 's443971689']
[32448.0, 32408.0, 32640.0]
[242.0, 212.0, 247.0]
[449, 433, 432]
p02684
u475503988
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = map(int, input().split())\nA = list(map(int, (input().split())))\n\ndone = [0]*N\nnow = 0\ncnt = 1\nwhile True:\n if done[now] != 0:\n start = done[now] - 1\n cycle = cnt - start - 1\n break\n else:\n done[now] = cnt\n now = A[now]-1\n cnt += 1\nif K>=start:\n ...
['Wrong Answer', 'Accepted']
['s627333073', 's672868677']
[32396.0, 32372.0]
[210.0, 182.0]
[410, 397]
p02684
u475675023
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k,*a=map(int,open(0).read().split())\nb=[1]\ns_b={1}\nfor i in range(n):\n tmp=a[b[-1]-1]\n if tmp in s_b:\n idx=b.index(tmp)\n break\n else:\n b.append(tmp)\n s_b|={tmp}\nmod=len(b[idx:])\nd=len(b[:idx])\nprint(d,(k-d)%mod)\nprint(b[d+(k-d)%mod])', 'n,k,*a=map(int,open(0).read().split())\na=[0]+a\na...
['Wrong Answer', 'Accepted']
['s401390064', 's208002444']
[33592.0, 31792.0]
[171.0, 1325.0]
[250, 127]
p02684
u476674874
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
["import numpy as np\ndef read_int():\n return int(input())\n\ndef read_ints():\n return map(int, input().split())\n\ndef read_lines(N):\n return [input() for i in range(N)]\n\ndef main():\n N, K = read_ints()\n towns = np.array(list(read_ints())) - 1\n portals = {i: towns[i] for i in towns}\n\n lo...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s003676130', 's315427903', 's407254503', 's585218955']
[57668.0, 12428.0, 51096.0, 32484.0]
[2207.0, 30.0, 2206.0, 146.0]
[812, 799, 821, 1174]
p02684
u478378139
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['tem1=input().split()\nN = int(tem1[0])\nK = int(tem1[1])\ntem2 = input().split()\nnow =1\nfact = K%N\nfor i in range(0,fact):\n now = int(tem2[now-1])\nprint(now)', 'tem1=input().split()\nN = int(tem1[0])\nK = int(tem1[1])\ntem2 = input().split()\njud = [0 for i in range(len(tem2))]\nnow =1\ncircle=0\nfor i in ran...
['Wrong Answer', 'Accepted']
['s957997166', 's394393427']
[24460.0, 30804.0]
[94.0, 194.0]
[157, 389]
p02684
u478719560
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import sys\n#from collections import defaultdict, deque, Counter\n\n#import heapq\n#import math\n#from itertools import accumulate\n#from itertools import permutations as perm\n#from itertools import combinations as comb\n#from itertools import combinations_with_replacement as combr\n#from fractions import gcd\n#impo...
['Wrong Answer', 'Accepted']
['s709314575', 's528248406']
[32272.0, 32372.0]
[2207.0, 151.0]
[1179, 1221]
p02684
u480847874
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['def m():\n n, k = map(int, input().split())\n a = [0] + list(map(int, input().split()))\n visited = [[] for _ in range(n + 1)]\n visited[1].append(0)\n cur = 1\n i = 1\n while True:\n cur = a[cur]\n visited[cur].append(i)\n i += 1\n if len(visited[cur]) >= 2:\n ...
['Wrong Answer', 'Accepted']
['s810622195', 's152662838']
[43448.0, 43516.0]
[2207.0, 213.0]
[669, 681]
p02684
u485979475
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import sys\nn,k=map(int,input().split())\nalist=list(map(int,input().split()))\n\nvislist=[1]\nvisset={1}\nloopflag=True\nendflag=False\ndonek=0\nima=1\n\nwhile loopflag:\n ima=alist[ima-1]\n if ima in visset:\n loopflag=False\n if ima == alist[ima-1]:\n endflag=True\n else:\n ...
['Wrong Answer', 'Accepted']
['s459426820', 's954529397']
[32640.0, 32556.0]
[167.0, 157.0]
[707, 695]
p02684
u486074261
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['from sys import stdin\n\n\ndef main():\n N, K = [int(x) for x in stdin.readline().rstrip().split()]\n As = [int(x) for x in stdin.readline().rstrip().split()]\n\n done = [0] * N\n step = -1\n start = 0\n current = 1\n between = 0\n\n while True:\n if done[current - 1] > 0:\n ...
['Wrong Answer', 'Accepted']
['s611976863', 's806359754']
[32168.0, 33572.0]
[148.0, 162.0]
[679, 715]
p02684
u487594898
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['#!/usr/bin/env python3\n\nimport sys\n\n\ninput = sys.stdin.readline\n#n = int(input())\n#n,k = map(int,input().split())\n#A = list(map(int,input().split()))\n#s=input()\n#a = input()\nn,k= map(int,input().split())\nA = [0]\nA += list(map(int,input().split()))\nB = [-1 for _ in range(n+1)]\nB[1] = 0\nnow =1\ncnt = 0...
['Wrong Answer', 'Accepted']
['s011583777', 's748974618']
[31260.0, 32248.0]
[196.0, 159.0]
[582, 386]
p02684
u490195279
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['from numba import njit\nimport numpy as np\n\n\ndef main(N, K, A):\n d = np.zeros(N,np.int32)\n d=d-1\n p = 0\n for i in range(K):\n if d[p-1] == 0:\n d[p-1] = i\n p = A[p-1]\n else:\n p = A[p-1]\n loop = i-d[p-1]\n nokori = (K-d[p-1]) %...
['Wrong Answer', 'Accepted']
['s935201542', 's675874452']
[115268.0, 115320.0]
[435.0, 701.0]
[506, 514]
p02684
u493318999
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k = map(int,input().split())\na = list(map(int,input().split()))\nnum = [a[0]]\nwhile True:\n for i in range(len(num)-1):\n if num[i] == num[-1]:\n break\n num.append(a[num[-1]])\nindex = index(a[-1])\nlstart = len(a[:index-1])\nlroop = len(a[index])\nnumber = (k-lstart)%lroop\nfor i in rang...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s063570011', 's213846390', 's350664943']
[32296.0, 50880.0, 50948.0]
[2206.0, 334.0, 340.0]
[374, 611, 738]
p02684
u502126017
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\na=list(map(int,input().split()))\ntown=[1]\ncnt=0\nloop=0\nindex=0\nwhile(len(town) <= k):\n town.append(a[town[-1]-1])\n cnt+=1\n index=len(town)-1\n if cnt != index:\n loop = cnt - index\n town.pop(-1)\n break\n\nif k<index:\n print(town[k])\nelse:\n...
['Runtime Error', 'Accepted']
['s097569271', 's611531424']
[63616.0, 32380.0]
[2207.0, 189.0]
[350, 288]
p02684
u509739538
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['import math\nimport queue\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor ...
['Runtime Error', 'Accepted']
['s460674707', 's287554482']
[32228.0, 32160.0]
[164.0, 160.0]
[2224, 2363]
p02684
u511449169
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['while True:\n k -= 1\n cnt += 1\n if k == 0:\n break\n dir = a[dir - 1]\n if hash_a[dir - 1] == 0 or hash_a[dir - 1] == 1 or hash_a[dir - 1] == 2:\n hash_a[dir - 1] += 1\n if hash_a[dir - 1] == 2:\n two += 1\n elif hash_a[dir - 1] == 3:\n k = (k + cnt) - (cnt -...
['Runtime Error', 'Accepted']
['s607320384', 's549066938']
[9140.0, 32404.0]
[24.0, 362.0]
[386, 527]
p02684
u511457539
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['# = int(input())\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\nnext = 1\nList = [-1]*N\n\nfor i in range(K):\n if List[next-1] == -1:\n List[next-1] = i\n next = A[next-1]\n\n else:\n loop = i - List[next-1]\n afterloop = (K-(i-loop+1))%loop\n pri...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s823940021', 's851500420', 's807071584']
[32376.0, 32384.0, 32300.0]
[168.0, 162.0, 128.0]
[460, 458, 458]
p02684
u511501183
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['\ndef solve(N,K,A):\n idx = [-1 for _ in range(len(A))]\n now = 0\n period = 0\n bias = 0\n tmp = []\n for i in range(K+1):\n tmp.append(now+1)\n if idx[now] == -1:\n idx[now] = i\n else:\n period = i - idx[now]\n cycle = tmp[-period-1:-1]\n ...
['Wrong Answer', 'Accepted']
['s806610634', 's510091732']
[32356.0, 33964.0]
[77.0, 171.0]
[868, 729]
p02684
u516566941
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N,K = map(int,input().split())\nsys.setrecursionlimit(20000000)\nA = list(map(int,input().split()))\nadj_list=[0]*N\nfor i in range(N):\n adj_list[i]=(A[i])\nk=0\nnode = 1\nc=[0]*N\ncount=1\nflag=0\nROOP=[]\nroopstart=0\nwhile k<K:\n k+=1\n c[node-1]+=1\n node = adj_list[node-1]\n if c[node-1] ==1:\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s250512529', 's524242464', 's599926538']
[9272.0, 9252.0, 32328.0]
[22.0, 26.0, 212.0]
[486, 486, 493]
p02684
u517447467
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['N, K = map(int, input().split())\nM = list(map(lambda x: int(x)-1, input().split()))\ns = 0\norder = [s]\nsets = set(order)\nwhile True:\n if M[s] in sets:\n #print(order, M[s])\n K -= order.index(M[s])\n order = order[order.index(M[s]):]\n print(order[K%len(order)-1]+1)\n break\n order.append(M[s])\...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s768406431', 's852346533', 's446041122']
[32320.0, 32256.0, 32300.0]
[213.0, 183.0, 177.0]
[335, 409, 402]
p02684
u517910772
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['def d():\n N, K = map(int, input().split())\n # A = list(map(int, input().split()))\n print(\'A = {}\'.format(A))\n warps = [1]\n\n for i in range(K):\n city = A[warps[-1] - 1]\n # print(\'city, warps = {}, {}\'.format(city, warps))\n if city in warps:\n loop_start_index...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s118300557', 's170040648', 's664262069', 's949394974', 's667339213']
[9212.0, 58356.0, 32296.0, 146936.0, 32256.0]
[24.0, 658.0, 2206.0, 3677.0, 129.0]
[575, 569, 573, 571, 1024]
p02684
u518064858
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n,k=map(int,input().split())\np=list(map(int,input().split()))\na=[0]+p\nflag=0\nbef=1\ntown=[1]\ntown_set=set(town)\ncnt=0\nwhile flag==0 and cnt<k:\n if not a[bef] in town_set:\n town.append(a[bef])\n town_set.add(a[bef])\n bef=a[bef]\n else:\n flag=1\n memo=a[bef]\n ...
['Wrong Answer', 'Accepted']
['s627244018', 's890580504']
[33868.0, 33852.0]
[221.0, 211.0]
[472, 480]
p02684
u518386853
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nl = [0]*n\ns = set()\nx = 0\n\nfor i in range(n):\n machi = a[x]\n if machi in s:\n hajime = l.index(machi)\n owari = i-1\n repeat = l[hajime:owari+1]\n print(l)\n break\n x = machi-1\n l[i] = machi...
['Wrong Answer', 'Accepted']
['s771060367', 's095735089']
[33532.0, 33552.0]
[216.0, 202.0]
[546, 434]
p02684
u522293645
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
['from collections import deque\n\nn,k = map(int,input().split())\nli = list(map(int,input().split()))\n\nfor i,l in enumerate(li):\n li[i]-=1\n\ndone = [0]*n\nroot = []\nque = deque()\n\ndone[0] = 1\nroot.append(0)\nque.append(li[0])\n\n\nwhile(len(que)!=0 and len(root)<k+1):\n v = que.pop()\n \n if done[v]!=0:\n...
['Wrong Answer', 'Accepted']
['s742930725', 's939103564']
[32716.0, 33800.0]
[246.0, 217.0]
[688, 675]
p02684
u525796732
2,000
1,048,576
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
[' \nimport sys\nstdin=sys.stdin\n\nns = lambda:stdin.readline().rstrip()\nni = lambda:int(stdin.readline().rstrip())\nnm = lambda:map(int,stdin.readline().split())\nnl = lambda:list(map(int,stdin.readline().split()))\n\nN,K=nm()\nA=nl()\n\nD=60\nMAX_N=2000005\nto=[[0]*MAX_N for i in range(D)]\n\nto[0][1:N+1...
['Time Limit Exceeded', 'Accepted']
['s784817248', 's483024597']
[958436.0, 32256.0]
[2232.0, 151.0]
[492, 745]