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 | u527454768 | 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]\nB=list(map(int, input().split()))\nfor m in range(N):\n A.append(B[m])\nplace=set([])\np=[]\ni=1\ncount=0\nwhile i not in place:\n place.add(i)\n p.append(i)\n i=A[i]\n count+=1\nif count>=K:\n print(p[K])\nelse:\n loop=[i]\n start=i\n j=A[i]\n co... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s046072812', 's132602683', 's275200247', 's501992085', 's710122733', 's343342947'] | [33916.0, 34112.0, 33400.0, 9088.0, 32404.0, 33816.0] | [185.0, 183.0, 176.0, 24.0, 2206.0, 230.0] | [475, 486, 482, 485, 364, 491] |
p02684 | u531599639 | 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 = [-1]*(N+1)\npath = []\nat = 1\ncount = 0\nwhile True:\n if visited[at] != -1:\n loop = count-visited[at]\n if K < count: \n print(path[K]+1) \n else:\n print(path[(K-visited[at])%loop+visited... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s169839143', 's366391102', 's546194772'] | [32324.0, 32376.0, 32300.0] | [115.0, 124.0, 169.0] | [580, 310, 312] |
p02684 | u535010493 | 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()))\npath = []\n\nnow = a[0]\npath.append(now)\n\nfor i in range(1, k+1):\n now = a[now-1]\n if now in path:\n now = a[a.index(now) + (k-i)%(len(path) - a.index(now) - 1)]\n break\n path.append(now)\n\nprint(now)\n', 'n, k = map(... | ['Runtime Error', 'Accepted'] | ['s135562044', 's597590547'] | [32328.0, 32172.0] | [2206.0, 178.0] | [288, 440] |
p02684 | u536034761 | 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(" "))\nrouts = {}\ntereporter = list(map(int, input().split()))\nfor i in range(N):\n routs[i + 1] = tereporter[i]\npresent_location = 1\nn = 0\nfor i in range(K):\n n += 1\n present_location = routs[present_location]\n if present_location = 1:\n if n == 0 or K % n == 0:\n br... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s557953075', 's696800639', 's979066444', 's176243484'] | [9056.0, 8924.0, 40404.0, 32376.0] | [24.0, 23.0, 103.0, 135.0] | [421, 615, 243, 392] |
p02684 | u538808095 | 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, K = map(int, input().split())\n\nA = list(map(int, input().split()))\n\nvisitcount = dict()\nn_point = list()\n\nx = 1\ncount = 0\nwhile(x not in set(visitcount)):\n visitcount[x] = count\n n_point.append(x)\n x = A[x-1]\n count += 1\n \nperiod = count - visitcount[x]\n\nif (K ... | ['Runtime Error', 'Accepted'] | ['s680427559', 's627223020'] | [9016.0, 56080.0] | [24.0, 262.0] | [417, 411] |
p02684 | u547608423 | 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=[]\n\nj=0 \nwhile A[j] not in ans:\n ans.append(A[j])\n j=A[j]-1\nans.append(A[j])\n\nst=ans.index(A[j])\nans=ans[st:-1]\nK-=st\nl=len(ans)\nprint(ans)\nprint(ans[K%l-1])', 'N,K=map(int,input().split())\nA=list(map(int,input().split()))\n\nan... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s669860367', 's830478607', 's943844711'] | [32380.0, 32384.0, 35412.0] | [2206.0, 66.0, 321.0] | [238, 320, 385] |
p02684 | u548069143 | 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(int, input().split()))\nb=[1]\nc=0\nm=0\n# while flag==1:\nfor i in range(n):\n if a[m] not in b:\n b.append(a[m])\n c+=1\n m=a[m]-1\n else:\n e=a[m]\n break\n\ne=b.index(e)\nprint(b,e)\nb=b[e:c+1]\nf=c+1-e\nif 1 not in b:\n ans=(e... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s403047271', 's975638134', 's371558856'] | [32384.0, 32304.0, 32304.0] | [2206.0, 181.0, 193.0] | [358, 393, 486] |
p02684 | u548976218 | 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()))\nr = 1\nroot = [1]\nfor _ in range(n):\n roo = A[r-1]\n root.append(roo)\nfor i in range(n):\n if roo == root[i]:\n roopcount = n-i-1\n break\nif k <= n:\n print(root[k-1])\nelse:\n s = k%n\n print(root[i])', 'n, k =... | ['Wrong Answer', 'Accepted'] | ['s571193109', 's342981820'] | [32308.0, 32300.0] | [102.0, 132.0] | [293, 341] |
p02684 | u552201227 | 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()))\nlst=[0]\nnow=0\nmemo=0\ntown=[0]*n\ntown[0]=1\nb=0 \nfor i in range(k):\n now=a[now]\n if town[now]==1:\n memo=now \n b=1\n break\n lst.append(now)\n town[now]=1\nif b==1:\n i=lst.index(now)\u3000\n l=len(lst)\n if mem... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s070208883', 's677017408', 's700375212', 's732804921', 's632721797'] | [9072.0, 9064.0, 9072.0, 9084.0, 32328.0] | [23.0, 23.0, 24.0, 25.0, 152.0] | [431, 410, 474, 522, 384] |
p02684 | u552741877 | 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\nh = set([])\n\nc = 0\nfor i in range(2 * n):\n c = a[c] - 1\n if n < i:\n print("{} {}".format(i, c))\n if c in h:\n break\n else:\n h.add(c)\n\n\nc = 0\nd = 1\nfor i in range(n):\n c = a[c] - 1\n print("{} {}".format(i, c)... | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s298103539', 's767806830', 's938150383', 's407945313'] | [34644.0, 34784.0, 34692.0, 34680.0] | [457.0, 257.0, 326.0, 202.0] | [511, 421, 466, 436] |
p02684 | u563838154 | 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())\ns = list(map(int,input().split()))\n# print(s)\nnow_city = 1\ns_l_city = 1\nt = [0] \nf = [0] \na=0\nb = 0\nf_l=0\nfor i in range(n):\n t.append(0)\n f.append(-1)\n# print(s)\nsycle = 0\nfor i in range(1,n+10):\n now_city = s[now_city-1]\n \n if t[now_city-1]==1:\n ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s162692464', 's571634191', 's035179618'] | [32260.0, 32392.0, 32204.0] | [262.0, 237.0, 237.0] | [1054, 1049, 1057] |
p02684 | u564525445 | 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\nlines = sys.stdin.readlines()\nN, M, X = map(int, lines[0].split())\nA = []\nC = []\n\nfor i in range(N):\n line = list(map(int, lines[i+1].split()))\n A.append(line[1:])\n C.append(line[0])\n\n# return []\ndef full_search():\n costs = []\n for i in range(2**N):\n vals = [0] * M\n ... | ['Runtime Error', 'Accepted'] | ['s108636027', 's139045161'] | [11480.0, 33688.0] | [26.0, 225.0] | [1254, 411] |
p02684 | u564770050 | 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()))\nns = [0] * (n+1)\ntree = []\n\nns = [0] * n\nns[0] = 1\n# max 2*10**5\n\nnexti = 0\nstarti = 0\nendi = 0\ntree.append(nexti)\n\nwhile k > 0 :\n nexti = a[nexti] - 1\n if ns[nexti] == 1:\n starti = nexti\n break\n ns[nexti] = ... | ['Runtime Error', 'Accepted'] | ['s624560335', 's764411947'] | [32168.0, 45992.0] | [153.0, 157.0] | [604, 376] |
p02684 | u567534852 | 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... | ['sys.setrecursionlimit(10**7)\n\ndef teleport(city, end, teleportmap, count=1):\n\n next_city = teleportmap[city]\n\n if count == end:\n return next_city\n\n else:\n return teleport(next_city, end, teleportmap, count+1)\n\nn, k = map(int,input().split())\na = list(map(int, input().split()))\ntel... | ['Runtime Error', 'Accepted'] | ['s238961969', 's016259505'] | [9144.0, 214956.0] | [24.0, 314.0] | [1092, 1134] |
p02684 | u571281863 | 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())\nt=list(map(int,input().split()))\ng=[1]\nfor i in range(N):\n gs=set(g)\n if t[g[i]-1] in gs:\n h=g.index(t[g[i]-1])\n s=i+1-h\n break\n g.append(t[g[i]-1])\nif K>h:\n K=(K-h)%s+h\nprint(g[K])\nprint(s,h)', 'N, K = map(int, input().split())\nT_list = list(map(int, input().sp... | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s366680572', 's394032799', 's692212269', 's395733681'] | [32284.0, 9032.0, 32240.0, 32396.0] | [2206.0, 23.0, 2206.0, 170.0] | [234, 624, 548, 229] |
p02684 | u576432509 | 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 bisect import bisect_right\nfrom bisect import bisect_left\n\nn,k=map(int,input().split())\na=list(map(int,input().split()))\n\n#n=6\n#k=727202214173249351\n#a=[6, 5, 2, 5, 3, 2]\n\nai=1\naj=[]\nfor i in range(min(n,k)):\n aim=ai\n ai=a[ai-1]\n# print(ai,aj)\n if ai in aj:\n# print(ai,aj)\n ... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s024632991', 's107574770', 's478621884'] | [32384.0, 32376.0, 32404.0] | [2206.0, 219.0, 159.0] | [492, 564, 471] |
p02684 | u580273604 | 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=[0]*(N+1)\nB[0]=1;c=0;d=0\nif B[0] in A:c=B[0]\nfor i in range(1,N+1):\n B[i]=A[B[i-1]-1]\n# if c==B[i]:break\n# if A.count(B[i])>1 and d==0:c=B[i];d+=1\n\nd=B.index(B[-1])\n#print(B.index(B[N-1]))\n#print(d)\n#print(B[-1])\n#print(B,d)\n\nif (K-d-1... | ['Wrong Answer', 'Accepted'] | ['s541504262', 's109487847'] | [32224.0, 32296.0] | [142.0, 130.0] | [421, 212] |
p02684 | u581022379 | 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(" "))\ntowns = [int(i)-1 for i in input().split(" ")]\nloopCount = 0\nnowPos = 0\nposList = [0]\nwhile not(nowPos==0 and loopCount!=0):\n nowPos = towns[nowPos]\n posList.append(nowPos)\n for i in range(0,len(posList)+1):\n for j in range(i+1,len(posList)):\n l... | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s022004701', 's196717129', 's602001292', 's058213209'] | [33432.0, 33436.0, 33536.0, 32360.0] | [2206.0, 2206.0, 2206.0, 178.0] | [785, 803, 720, 514] |
p02684 | u585613332 | 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()))\nt = list(map(int, input().split()))\n\nvisited = [False]*(2*10**5 + 10)\nval = 1\ncount = 0\nhold = k\nwhile hold > 0 :\n if visited[val] or val == t[val - 1]:\n break\n visited[val] = True\n val = t[val - 1]\n # print('a', val)\n count += 1\n hold -= 1... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s290944859', 's305817989', 's392356412'] | [32348.0, 32184.0, 32392.0] | [155.0, 2206.0, 187.0] | [753, 705, 819] |
p02684 | u591143370 | 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())\nList = list(map(int, input().split()))\n\na=[]\nb=1\nfor i in range(N):\n if not b in a:\n a[i]=b\n b=List[b-1]\n else:\n c=i\n break\n#print(a)\n#print(b,c)\nnum=a.index(b)\n#print(T,num)\nT=c-num\nif K<num:\n print(a[K])\nelse:\n print(a[num:]... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s340245886', 's782742896', 's234320193'] | [32328.0, 32364.0, 32240.0] | [68.0, 2206.0, 178.0] | [310, 353, 506] |
p02684 | u591295155 | 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 get_keys(d, val):\n return [k for k, v in d.items() if v == val]\n \ndef main():\n read = lambda: sys.stdin.readline().rstrip()\n \n N, K = map(int,read().split())\n A = list(map(int,read().split()))\n \n g = collections.defaultdict(int)\n for i, val in enumerate(A):\n g[i + 1] ... | ['Runtime Error', 'Accepted'] | ['s732420893', 's774488578'] | [9156.0, 60424.0] | [24.0, 240.0] | [694, 756] |
p02684 | u591812989 | 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()))\np = 1\nB = [-1]*N\nB[0] = 0\ncount = 1\nwhile K < count :\n\tp = A[p-1]\n\tif B[p-1] != -1:\n\t\tbreak\n\tB[p-1] = count\n\tcount += 1\nif K < count:\n\tprint(p)\n\treturn\nK -= count\nK = K % (count-B[p-1])\nfor i in range(K):\n\tp = A[p-1]\nprint... | ['Runtime Error', 'Accepted'] | ['s709344206', 's245729661'] | [9144.0, 32272.0] | [23.0, 130.0] | [297, 312] |
p02684 | u592547545 | 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 readinput():\n n,k=list(map(int,input().split()))\n a=list(map(int,input().split()))\n return n,k,a\n\ndef main(n,k,a):\n tbl={}\n for i in range(1,n+1):\n tbl[i]=a[i-1]\n machi=1\n for i in range(k):\n machi=tbl[machi]\n return machi\n\ndef main2(n,k,a):\n a.insert(0,0)\n... | ['Wrong Answer', 'Accepted'] | ['s177332523', 's507176368'] | [32388.0, 32404.0] | [161.0, 151.0] | [1789, 1790] |
p02684 | u593019570 | 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()))\n\nb = [1 for i in range(n)]\n\n\nnow = 0\nnext = -1\nc = []\nfor i in range(n):\n if b[next] == 0:\n d = c[:c.index(next)]\n e = [c[-1]] + c[c.index(next):-1]\n #print(d,e)\n break\n #print(now)\n b[now] = 0\n ... | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s429102382', 's452888343', 's489250142', 's857162046'] | [32252.0, 32256.0, 32360.0, 32256.0] | [189.0, 360.0, 359.0, 187.0] | [416, 521, 473, 516] |
p02684 | u595375942 | 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 itertools import combinations\nimport numpy as np\nN, M, X = map(int,input().split())\nxx = np.array([X]*M)\nC = {}\ncs = []\nfor _ in range(N):\n c, *A = map(int,input().split())\n C[c] = A\n cs.append(c)\nans = float('inf')\nfor i in range(0, N+1):\n for comb in combinations(cs,i):\n tmp = 0... | ['Runtime Error', 'Accepted'] | ['s227184051', 's938524202'] | [27164.0, 32376.0] | [111.0, 170.0] | [504, 386] |
p02684 | u595893956 | 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\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\nalready = [False] * N\nstep = 0\nnow = 1\ncount = 1\nwhile(already[now-1] != True):\n already[now - 1] = True\n now = A[now - 1]\n count += 1\n if count - 1 == K:\n print(now)\n exit(0)\n\n\n\nif(now-1 == 0)... | ['Wrong Answer', 'Accepted'] | ['s488388248', 's636648133'] | [32180.0, 32384.0] | [200.0, 191.0] | [729, 1030] |
p02684 | u596681540 | 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 = [int(a) for a in input().split()]\n\n\n# print(A_list)\n\nkeiro = [1]\nvisit_town = [0]*N\n\ntown = 1\nc = 1\nwhile True:\n visit_town[town - 1] = c\n c += 1\n town = A_list[town - 1]\n \n\n if len(keiro) > 1 and visit_town[town-1] != 0:\n break\n ... | ['Runtime Error', 'Accepted'] | ['s310205578', 's034692498'] | [32288.0, 32256.0] | [271.0, 178.0] | [814, 812] |
p02684 | u597455618 | 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\ndef main():\n n, k = map(int, sys.stdin.buffer.readline().split())\n a = [0] + list(map(int, sys.stdin.buffer.readline().split()))\n\n visited = [0]*(n+1)\n town = 1\n for i in range(k+1):\n town = a[town]\n if visited[town] == 0:\n visited[town] = i\n else... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s074542349', 's090562553', 's202710108', 's681462509', 's768544267', 's494198021'] | [27796.0, 27800.0, 32228.0, 27964.0, 27968.0, 27812.0] | [98.0, 109.0, 2206.0, 102.0, 102.0, 102.0] | [472, 473, 370, 496, 472, 496] |
p02684 | u601620345 | 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\nimport math \nN, K=map(int,input().split())\nA2 = np.zeros(N)\nA = list(map(int,input().split()))\nA = list(map(lambda x: x -1 , A))\ncurrent_town = 0\n\n\n\ni=0\nwhile i<K:\n current_town = A[current_town]\n if A2[current_town] != 0:\n cycle = i - A2[current_town] \n i = K - ... | ['Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s464654269', 's652493006', 's675431638', 's042769419'] | [51028.0, 51016.0, 51040.0, 51072.0] | [2206.0, 2207.0, 2206.0, 278.0] | [379, 380, 476, 294] |
p02684 | u602773379 | 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 input2():\n\treturn map(int,input().split())\n\n\ndef input_array():\n\treturn list(map(int,input().split()))\n \nn,k=input2()\nA=input_array()\n\n\ntmps=[1] \nloops=[] \ncount=0 \n\nfor i in range(2*(10**5)+1):\n\tif A[count] not in tmps:\n\t\ttmps.append(A[count])\n\telif (A[count] in tmps) and (A[count] not... | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s175111465', 's285131189', 's439279456', 's735408547', 's838240267', 's992784282', 's843128025'] | [32364.0, 32384.0, 32296.0, 9100.0, 32244.0, 32308.0, 32268.0] | [2206.0, 183.0, 2206.0, 26.0, 2206.0, 2206.0, 154.0] | [655, 554, 654, 433, 631, 605, 566] |
p02684 | u606146341 | 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())\nlst = list(map(int, input().split()))\n\nvisited = [0] * n\nflg = 1\ni = 0\nnow = 0\nwhile flg:\n if visited[now] == 0:\n i += 1\n visited[now] = i\n now = lst[now] \n else:\n break\nprint(i, now, visited)\n\nk_bk = k - visited[now]\nk_bk = k_bk // ... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s072059698', 's520926107', 's777931697', 's455744030'] | [32364.0, 32332.0, 32396.0, 32252.0] | [113.0, 167.0, 111.0, 134.0] | [439, 471, 425, 462] |
p02684 | u607563136 | 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\ndef main():\n N,K = map(int,input().split())\n A = [0]\n A += list(map(int,input().split()))\n A = np.array(A)\n \n s_time =time.time()\n i = 1\n pas = np.zeros(N)\n pas[0] = i\n k = 1\n pass_set = set(pas)\n while k <= K:\n if A[i] in pass_set:\n ... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s544228602', 's690052530', 's820724599', 's471451068'] | [51028.0, 8996.0, 32280.0, 32208.0] | [169.0, 25.0, 161.0, 157.0] | [605, 418, 415, 491] |
p02684 | u607865971 | 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 = [int(x) - 1 for x in input().split()]\n\ni = 0\nT = []\nS = set()\nst = 0\nwhile True:\n T.append(i)\n S.add(i)\n i = A[i]\n if i in S:\n st = T.index(i)\n break\n\nprint(T)\n\nidx = (K - st) % (len(T) - st)\nprint(T[st + idx] + 1)\n\n\n\n', 'N, ... | ['Wrong Answer', 'Accepted'] | ['s572019124', 's255691027'] | [32548.0, 32620.0] | [205.0, 155.0] | [289, 334] |
p02684 | u607884285 | 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(' ')))\nloc=1\nbegin=0\nend=0\nd={1:0}\nfor i in range(n+1):\n loc=a[loc-1]\n if loc in d.keys():\n begin=d[loc]\n end=i+1\n break\n d[loc]=i+1\nif k<=end:\n end=0\nif end==begin+1:\n k=begin\n end=0\nif end !=0:\n ... | ['Wrong Answer', 'Accepted'] | ['s270104728', 's665261427'] | [38880.0, 39040.0] | [224.0, 223.0] | [386, 428] |
p02684 | u608007704 | 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\ncache={}\nlog=[]\nA = list(map(lambda x:int(x)-1, input().split(' ')))\n\nnow=0\n\nwhile(True):\n log.append(now)\n cache[now]=1\n now=A[now]\n if(cache.get(now)):break\n\nloop_start=log.index(now)\nloop_end=len(log)\nloop=loop_end-loop_start\n#print(loop_end-loop_start,loop_... | ['Wrong Answer', 'Accepted'] | ['s287274837', 's364957973'] | [35528.0, 35760.0] | [208.0, 166.0] | [458, 356] |
p02684 | u609307781 | 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... | ["# D\n\nN, K = list(map(int, input().split()))\nAs = list(map(int, input().split()))\n\ndef compute(city, K):\n for i in range(K):\n # print('\\t', city)\n city = As[city-1]\n print(city)\n\n\nif N > K:\n compute(1, K)\n\ncities_visited = [False] * N\ni = 0\ncity = 1\ncity_visited_time = {}\n\nw... | ['Runtime Error', 'Accepted'] | ['s733193197', 's201317373'] | [9168.0, 45892.0] | [24.0, 214.0] | [739, 652] |
p02684 | u614162316 | 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\ns=[]\nd=[-1]*(n+1)\n\nv=1\nwhile(d[v]==-1):\n d[v]=len(s)\n s.append(v)\n v=a[v-1]\nc=len(s)-d[v]\nl=d[v]\n\nif(k<l):print(s[k])\nelse:\n k-=l\n k%=c\n print(k+l)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\n\ns=... | ['Wrong Answer', 'Accepted'] | ['s263791134', 's738626105'] | [32300.0, 32380.0] | [145.0, 180.0] | [228, 231] |
p02684 | u620238824 | 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\nB = [0] * N\nC = 0\nD = 0\nE = []\nfor i in range(K):\n if i == 0:\n B[i] += 1\n C = A[0]\n D += 1\n E.append(C)\n #print(i, C)\n \n else:\n if B[C - 1] == 0:\n B[C - 1] += ... | ['Runtime Error', 'Accepted'] | ['s225496931', 's011082887'] | [32376.0, 32376.0] | [162.0, 189.0] | [581, 838] |
p02684 | u623659526 | 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 logging\n\nlogging.basicConfig(level=logging.INFO, format="%(message)s")\n\n\n\ndef main():\n N, K = map(int, input().split())\n A_i = list(map(int, input().split()))\n B_i = []\n cycle_list = []\n \n cycle = 0\n diff = 0\n counter = 0\n machi = 1\n for num in A_i:\n if mac... | ['Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Accepted'] | ['s103312543', 's409867243', 's752432712', 's996553952', 's924231521'] | [33940.0, 33960.0, 33964.0, 33936.0, 33972.0] | [116.0, 153.0, 2206.0, 86.0, 160.0] | [628, 761, 642, 761, 876] |
p02684 | u623687794 | 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()))\nfor i in range(N):\n a[i]-=1\nif a[0]==1:print(1);exit()\nc=dict()\nvisited=[False]*N\nvisited[0]=True\nc[0]=0\ncnt=0\ndap=0\nn=0\nb=[0]\nwhile True:\n n=a[n]\n if visited[n]:\n dap=c[n] \n break\n visited[n]=True\n b.append(... | ['Wrong Answer', 'Accepted'] | ['s725457401', 's003415444'] | [40664.0, 40656.0] | [222.0, 208.0] | [368, 404] |
p02684 | u632125181 | 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\ns = sys.stdin.readlines()\nN, K = map(int, s[0].split())\nA = list(map(int, s[1].split()))\n\nb = [1]\ni = 0\nwhile True:\n if A[i] in b:\n# print("m: "+str(b.index(A[i])))\n# print("n: "+str(len(b)-A[i]))\n m = b.index(A[i])\n n = len(b)-A[i]\n K = (K-m)%n + m\n ... | ['Runtime Error', 'Accepted'] | ['s624810824', 's726692200'] | [32496.0, 32344.0] | [2206.0, 177.0] | [444, 587] |
p02684 | u633255271 | 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(lambda x: int(x) - 1, input().split()))\n\nnow = 0\nroute = []\nwhile True:\n route.append(now)\n to = A[now]\n if to == None:\n break\n else:\n A[now] = None\n now = to\n\nprint(route)\n\nloop_start = route.index(now)\nloop_size = ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s915018153', 's924675567', 's661014862'] | [32356.0, 32144.0, 115464.0] | [179.0, 145.0, 1755.0] | [440, 426, 239] |
p02684 | u636290142 | 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\nroop_num = 1\ncity = 0\nfirst_city = 0\n\nwhile True:\n next_city = A[city] - 1\n if next_city == first_city:\n break\n if roop_num == K:\n print(city + 1)\n exit()\n city = next_city\n roop_num += 1\n\nrem_nu... | ['Wrong Answer', 'Accepted'] | ['s435845541', 's874525699'] | [32360.0, 32316.0] | [2206.0, 154.0] | [482, 679] |
p02684 | u638033979 | 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\nimport numpy as np\nn,k =map(int,input().split())\nA = [int(x)-1 for x in input().split()]\narrive_time = [0]*n\ntime = 1\ndone = [0]*n\ndone[A[0]] = 1\narrive_time[A[0]] = time\nlast = 0\nwhile True:\n v = A[0]\n if done[A[v]] == 0:\n done[A[v]] = 1 \n time += 1\n ... | ['Wrong Answer', 'Accepted'] | ['s896792198', 's364702666'] | [51080.0, 51088.0] | [201.0, 342.0] | [700, 713] |
p02684 | u642012866 | 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, ("0 "+input()).split()))\n\n\nc = [0]*(N+1)\ni = 1\ncnt = 0\nf = True\n\nwhile cnt < K:\n if f and c[A[i]]:\n print(cnt, i, c)\n loop = cnt-c[A[i]]\n cnt += (K-cnt-1)//loop*loop\n if cnt == K:\n break\n f = False\n\n ... | ['Runtime Error', 'Accepted'] | ['s250319972', 's008349841'] | [32332.0, 32384.0] | [158.0, 136.0] | [349, 300] |
p02684 | u648881683 | 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().rstrip() \nsys.setrecursionlimit(10**7)\nINF = 10**20\ndef I(): return int(input())\ndef F(): return float(input())\ndef S(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [fl... | ['Runtime Error', 'Accepted'] | ['s071844339', 's881193476'] | [9188.0, 33440.0] | [22.0, 146.0] | [922, 930] |
p02684 | u648901783 | 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\n\n\n\ntrace = [0]*N\nloop_start = 0\nloop_before = 0\ncnt = 0\nall_cnt = 0\n\nif K > N:\n loop = 0\n now = 0\n while(1):\n # print(trace)\n trace[now] += 1\n if trace[now] == 3:\n break\n if trace[no... | ['Wrong Answer', 'Accepted'] | ['s224536015', 's625294063'] | [32392.0, 32392.0] | [2206.0, 186.0] | [1070, 1069] |
p02684 | u652656291 | 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(input()) for _ in range(n)]\nB = []\nb = 1\nans = 1\nwhile ans:\n a = b\n b = A[a-1]\n B.append(b)\n if len(B) == len(A):\n ans = 0\n else:\n continue\n\nprint(B[k-1])\n', 'n,k = map(int,input().split())\nA = list(map(int,input().split()))\nB = []\nb = 1\nans = 1\nw... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error'... | ['s038166217', 's232172712', 's241688526', 's243465174', 's257061570', 's326564683', 's328371768', 's364176024', 's403142475', 's468744717', 's518701662', 's555507388', 's579006661', 's713937245', 's747295369', 's770234868', 's801493203', 's872188543', 's903435124', 's940460010', 's957961326', 's988655596', 's396998017... | [11496.0, 32292.0, 32228.0, 32380.0, 32376.0, 32324.0, 32356.0, 32268.0, 32296.0, 32368.0, 32372.0, 32384.0, 32396.0, 32364.0, 32380.0, 9036.0, 32376.0, 32380.0, 32316.0, 32296.0, 32124.0, 152444.0, 32676.0] | [34.0, 148.0, 175.0, 158.0, 149.0, 196.0, 181.0, 64.0, 67.0, 161.0, 139.0, 159.0, 194.0, 65.0, 225.0, 25.0, 68.0, 185.0, 153.0, 148.0, 149.0, 2211.0, 206.0] | [206, 233, 204, 210, 160, 193, 201, 87, 210, 196, 216, 202, 228, 192, 233, 152, 227, 183, 190, 172, 179, 127, 352] |
p02684 | u654590131 | 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\nA.insert(0,-1)\nroot = [1]\nnext = A[1]\nrf = 0\n\nfor _ in range(K):\n if next not in root:\n root.append(next)\n next = A[next]\n else:\n rf = root.index(next)\n roop = root[rf:]\n break\n\n\nprint(root[... | ['Runtime Error', 'Accepted'] | ['s950094226', 's127503674'] | [32376.0, 32284.0] | [2206.0, 120.0] | [327, 306] |
p02684 | u657719194 | 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()))\nvisited = [False for _ in range(n+1)]\npos = 1\nx = []\nflg = False\nfor i in range(k):\n if visited[pos] == False:\n x.append(pos)\n visited[pos] = True\n pos = A[pos]\n else:\n flg = True\n pre = x.index... | ['Runtime Error', 'Accepted'] | ['s309802254', 's486854781'] | [9092.0, 32372.0] | [24.0, 151.0] | [452, 415] |
p02684 | u657786757 | 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()))\ntour=[0]\nnext_town = 0\nfor i in range(n*2):\n next_town=A[next_town]-1\n if next_town in tour:\n first_roop_idx = tour.index(next_town)\n break\n tour.append(next_town)\n#print(tour)\nif k<=len(tour):\n ans = tour[k]... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s057951900', 's098398468', 's798348812', 's915355887', 's968483056', 's291907611'] | [32376.0, 34712.0, 32368.0, 32404.0, 32364.0, 32388.0] | [2206.0, 213.0, 143.0, 2206.0, 158.0, 168.0] | [408, 805, 648, 407, 809, 810] |
p02684 | u657994700 | 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\n# print('input >>')\nN, K = map(int,(input().split()))\nAs = list(map(lambda x: int(x)-1,(input().split())))\n\nvisited = [0] * N\nvisited[0] = 1\nroots = [0]\nnow = 0\n\n# print('-----output-----')\nwhile True:\n now = As[now]\n if visited[now] == 1:\n p = now\n rep_start = roots.in... | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s172204030', 's491014198', 's504168827', 's578703163', 's852546036', 's951318632', 's333268142'] | [32380.0, 32380.0, 32308.0, 32384.0, 32396.0, 32236.0, 32392.0] | [193.0, 2206.0, 229.0, 115.0, 164.0, 157.0, 174.0] | [711, 680, 747, 615, 719, 709, 692] |
p02684 | u661343770 | 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... | ['a, b = list(map(int, input().split()))\nc = list(map(int, input().split()))\nitta2 = set([])\nmati = 1\ni = 0\nitta = []\nt0 = time.time()\nwhile True:\n if mati in itta2:\n saisyo = mati\n break\n else:\n itta2.add(mati)\n itta.append(mati)\n mati = c[mati-1]\n i += 1\... | ['Runtime Error', 'Accepted'] | ['s249408327', 's264688863'] | [32388.0, 43428.0] | [67.0, 254.0] | [610, 532] |
p02684 | u661647607 | 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\nt = 0\nnow = 1\nfootprint = [1]\n\nwhile t < K:\n if A[now-1] not in footprint:\n footprint.append(A[now-1])\n now = A[now-1]\n t += 1\n continue\n else:\n s = footprint.index(A[now-1])\n l = t - s + 1\n e = K % l\n now... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s231171129', 's299827963', 's673649577', 's578863710'] | [32396.0, 32376.0, 32412.0, 32372.0] | [2206.0, 2206.0, 2206.0, 166.0] | [340, 327, 331, 370] |
p02684 | u667949809 | 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... | ['dic = {}\nfor key, a in zip(range(1, n+1), list(map(int,input().split()))):\n dic[key] = a\n \nkeynum = 0\nlog = [-1]*(n+1)\nnext = dic[1]\nstep = 1\nlog[next] = step\nk -= 1\nwhile k:\n next = dic[next]\n step += 1\n k -= 1\n if log[next] != -1:\n k %= log[next] - step\n else:\n log[n... | ['Runtime Error', 'Accepted'] | ['s571533820', 's568543953'] | [9104.0, 32348.0] | [24.0, 141.0] | [324, 303] |
p02684 | u671211357 | 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\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\nans=[]\ndef saiki(B):\n if len(B)==K+1:\n ans.append(B)\n print(B[-1])\n return\n B.append(A[B[-1]-1])\n saiki(B)\nsaiki([1])\n#print(ans)', 'N,K=map(int,input().split())\nA=list(map(int,input().split()))\nk... | ['Runtime Error', 'Accepted'] | ['s804916641', 's043657039'] | [9004.0, 35948.0] | [26.0, 189.0] | [237, 686] |
p02684 | u671446913 | 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 collections\nimport itertools as it\nimport math\n#import numpy as np\n \n# = input()\n# = int(input())\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\n#\n# c = collections.Counter()\n\nord_ = [-1] * (n + 1) \ns = []\ncurrent = 0\nwhile ord_[v] == -1:\n or... | ['Runtime Error', 'Accepted'] | ['s623769368', 's712362171'] | [33720.0, 33724.0] | [72.0, 176.0] | [541, 743] |
p02684 | u677121387 | 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()]\nloc = 0\ncnt1 = 0\nseen = [False]*n\nseen[0] = True\nwhile not seen[loc]:\n loc = a[loc]\n cnt1 += 1\n if cnt1 == k:\n print(loc+1)\n exit()\ncnt2 = 0\nx = loc\nwhile loc != x:\n loc = a[loc]\n cnt2 += 1\ncnt1 -= cnt... | ['Runtime Error', 'Accepted'] | ['s524392274', 's022991292'] | [32328.0, 32324.0] | [79.0, 151.0] | [382, 338] |
p02684 | u678505520 | 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=[1]\nm=0\nj=0\nfor i in range(1,n):\n B.append(A[m])\n m=A[m]-1\n if B[i] in B[:i]:\n while B[j]!=B[i]:\n j+=1\n break\nT=len(B)-j-1\nif n!=2: \n print(B[k-((k-j)//T)*T],B)\nelse:\n print(B[k%2])', 'n,k = ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s907091536', 's926676646', 's070086612'] | [32360.0, 32388.0, 30960.0] | [2206.0, 68.0, 177.0] | [292, 266, 454] |
p02684 | u686036872 | 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 = [i-1 for i in A]\n\ncheck = [0]*N\ni = 0\nc = 0\ncheck = []\nvisited = [0]*N\nflag = False\nwhile c<=K:\n if visited[i] == 1:\n flag = True\n break\n else:\n check.append(i)\n visited[i] = 1\n i = A[i]\... | ['Runtime Error', 'Accepted'] | ['s688135934', 's985394803'] | [8984.0, 32256.0] | [20.0, 141.0] | [447, 427] |
p02684 | u686230543 | 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 zero_index(i: str) -> int:\n return int(i) - 1\n\nn, k = map(int, input().split())\ntransition = map(zero_index, input().split())\nplaces = [0]\nnext_place = transition[0]\nwhile next_place not in places:\n places.append(next_place)\n next_place = transition[next_place]\nstart = places.index(next_place)\nperio... | ['Runtime Error', 'Accepted'] | ['s263932734', 's718577630'] | [24464.0, 32176.0] | [41.0, 148.0] | [412, 481] |
p02684 | u687574784 | 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 -*-\nn, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nrem=k\nnxt=1\nvisit=[]\nvisit_set={}\nfor i in range(k):\n visit.append(nxt)\n visit_set.add(nxt)\n nxt=a[nxt-1]\n \n if nxt in visit_set:\n break\n rem-=1\n\nif rem==0:\n print(nxt)\nel... | ['Runtime Error', 'Accepted'] | ['s252819819', 's243281221'] | [32368.0, 32388.0] | [69.0, 174.0] | [557, 562] |
p02684 | u693007703 | 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().split()]\nX = [int(i) for i in input().split()]\n\ntown = []\ndic = {}\n\ni = 0\nj = 0\n\nwhile i not in dic and j < K:\n print('i', i)\n dic[i] = j\n town.append(i)\n i = X[i] - 1\n j += 1\n \nif j == K:\n output = i + 1\n \nelse : \n num = dic[i]\n loop ... | ['Wrong Answer', 'Accepted'] | ['s370483342', 's126931125'] | [33496.0, 33224.0] | [238.0, 154.0] | [370, 352] |
p02684 | u693723949 | 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 = [int(x)-1 for x in input().split()]\n\nvisited = [0]\norder = {}\norder[0] = 0\nx = 0\nT = -1\ni = 0\nwhile T<0:\n x = a[x]\n i+=1\n if x in visited:\n s = order[x]\n T = i - s\n break\n else:\n visited.append(x)\n order[x] = i\nif k < s:\n print(visit... | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s034441513', 's035990983', 's104720546', 's204852724', 's218204782', 's226492859', 's397404615', 's440870978', 's467895223', 's528791368', 's738340398', 's804957120', 's915135196', 's128896318'] | [32168.0, 32320.0, 32252.0, 32336.0, 32192.0, 9052.0, 32204.0, 9056.0, 32208.0, 32332.0, 32252.0, 32088.0, 32344.0, 32324.0] | [2206.0, 2206.0, 2206.0, 2206.0, 79.0, 26.0, 2206.0, 22.0, 2206.0, 2206.0, 2206.0, 2206.0, 75.0, 178.0] | [353, 326, 369, 126, 332, 309, 346, 326, 370, 315, 347, 380, 417, 423] |
p02684 | u694380052 | 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())\nli = list(map(int, input().split()))\n \ncheck = [0] * (n+10)\nres = []\nnext = 0\n \nfor i in range(k):\n if check[next] == 0:\n check[next] = 1\n next = li[next]-1\n elif check[next] == 1:\n check[next] += 1\n res.append(next+1)\n next = li[... | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s060283196', 's101062061', 's401791281', 's407687673', 's428304656', 's537286585', 's603973864', 's801189342', 's815450207', 's914457049', 's980584150', 's348932078'] | [32372.0, 9060.0, 8968.0, 32372.0, 9092.0, 9000.0, 32084.0, 32264.0, 9072.0, 32332.0, 9064.0, 32348.0] | [168.0, 26.0, 24.0, 168.0, 25.0, 24.0, 164.0, 168.0, 26.0, 170.0, 25.0, 160.0] | [434, 480, 352, 484, 981, 484, 381, 379, 985, 383, 487, 377] |
p02684 | u696444274 | 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 fractions import gcd\nfrom functools import reduce\nfrom collections import deque\n# from math import factorial\nimport collections\nimport math\nimport sys\nsys.setrecursionlimit(2000000)\n\nn, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ncheck = [0]*n\ncheck[0] = 1\nstack = [a[0]... | ['Wrong Answer', 'Accepted'] | ['s574432560', 's397153421'] | [33568.0, 32412.0] | [200.0, 162.0] | [708, 489] |
p02684 | u701893485 | 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... | ['if __name__=="__main__":\n N, K = map(int, input().split(\' \'))\n _town_list = input().split(\' \')\n town_list = [int(n) for n in _town_list]\n\n next_town = town_list[0]\n visited_town = set()\n visited_town.add(1)\n visited_town.add(next_town)\n lst_visited_town = [1]\n lst_visited_town... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s769471424', 's841331483', 's409697381'] | [44420.0, 44572.0, 44648.0] | [156.0, 157.0, 155.0] | [828, 827, 833] |
p02684 | u704284486 | 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=tuple(map(int,input().split()))\ns=1\nstate=[s]\ncount={}\nfor i in range(k+1):\n s=A[s-1]\n if s in count:\n start=len(state)\n end=i=1\n print(state[start+(k-start)%(end-start)])\n break\n else:\n count[state[i]]=i\n state.append[s]\... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s027248972', 's454465740', 's444308046'] | [32416.0, 32400.0, 32336.0] | [66.0, 70.0, 145.0] | [323, 353, 346] |
p02684 | u704470185 | 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\narray = input().split()\nfor i in range(len(array)):\n array[i] = int(array[i])\n\nnow = 1\n\nhistory = set()\nstart_number = -1\n\nfor i in range(K):\n history.add(now)\n now = array[now - 1]\n if(now in history):\n start_number = now\n break\n\nif not(st... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s693926741', 's902275946', 's505107701'] | [36104.0, 25380.0, 36596.0] | [156.0, 86.0, 192.0] | [483, 486, 529] |
p02684 | u707030679 | 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\nC[0]=1\nc=0\nloopc=0\ni=0\nwhile i<n :\n newi = A[i]-1\n C[newi]+=1\n if C[newi]>=3 :\n rs=newi\n break\n elif C[newi]==2 :\n loopc+=1\n i=newi\n c+=1\n\nmod = (k-(c-loopc))%(loopc+1)\n# print( C, c, lo... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s034471399', 's667452384', 's305661121'] | [32336.0, 32356.0, 32068.0] | [279.0, 306.0, 223.0] | [382, 380, 443] |
p02684 | u708019102 | 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 = [int(x) for x in input().split()]\ndoko = 0\nfor i in range(K):\n if A[doko] <= 0:\n saishou = min(A)\n loop = A[doko] - saishou + 1\n hajimarimade = A[doko]\n K += hajimarimade\n print(A)\n print(A.index(-1*(K % loop)+hajimarim... | ['Wrong Answer', 'Accepted'] | ['s785720834', 's306072054'] | [32176.0, 32328.0] | [180.0, 154.0] | [446, 425] |
p02684 | u724844363 | 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\nzyun = [a[0]]\nalr = [False]*n\nalr[0] = True\ncrr = a[0]\n\nkey = True\n\nwhile key:\n if not alr[crr - 1]:\n alr[crr - 1] = True\n crr = a[crr - 1]\n zyun.append(crr)\n continue\n else:\n index1 = crr\n... | ['Runtime Error', 'Accepted'] | ['s971727311', 's067762798'] | [32180.0, 33424.0] | [181.0, 158.0] | [780, 938] |
p02684 | u726285999 | 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(x) - 1 for x in input().split()]\n\n\nloop = 0\ncity = 0\nb = set([0])\nwhile True:\n loop += 1\n if A[city] in b:\n break\n else:\n city = A[city]\n b.add(city)\n\nloop_start = A[city]\n\n\npre = 0\ncity = 0\nwhile True:\n pre += 1\n if A... | ['Runtime Error', 'Accepted'] | ['s692746372', 's499346927'] | [32556.0, 32576.0] | [213.0, 275.0] | [779, 781] |
p02684 | u728473456 | 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()))\npos = 0\nvisit = [0] * n\nmove = []\nloop = []\nwhile visit[pos] != 2:\n if visit[pos] == 0:\n move.append(pos)\n else:\n loop.append(pos)\n visit[pos] += 1\n pos = a[pos] - 1\nif len(move[k]) > k:\n print(move[k]+1)\nels... | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s380764313', 's437365296', 's604706229', 's907201022', 's805041491'] | [32928.0, 32224.0, 50976.0, 51036.0, 32864.0] | [239.0, 68.0, 230.0, 2207.0, 231.0] | [361, 360, 443, 460, 358] |
p02684 | u728566015 | 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 numpy as np\nN, K = map(int, input().split())\nA = np.array(list(map(int, input().split())))\nA = np.insert(A, 0, 0)\n\nflg = [False for _ in range(N + 1)]\ntown = []\ni = 1\ncnt = 0\nfor i in range(N):\n town.append(i)\n flg[i] = True\n i = A[i]\n\nif len(town) >= K:\n print(town[K])\n... | ['Runtime Error', 'Accepted'] | ['s701260027', 's715413960'] | [51024.0, 51072.0] | [255.0, 248.0] | [411, 411] |
p02684 | u729133443 | 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())\nd=[2*k]*n\ns=0\nwhile k:k-=1;k%=d[s:=a[s]-1]-k;d[s]=k\nprint(s)', 'n,k,*a=map(int,open(0).read().split())\nd=[2*k]*n\nwhile k:n=1-a[-n];d[n]=k=~-k%(d[n]+1-k)\nprint(1-n)'] | ['Runtime Error', 'Accepted'] | ['s815474361', 's637653595'] | [9028.0, 31816.0] | [22.0, 168.0] | [99, 99] |
p02684 | u732061897 | 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())\nroutes = list(map(int, input().split()))\n\notozureta = set([1])\notozureta_list = [1]\n\n\ndef search(list, next):\n if not otozureta.isdisjoint(set([next])):\n return next\n else:\n otozureta.add(next)\n otozureta_list.append(next)\n return search(... | ['Runtime Error', 'Accepted'] | ['s432959840', 's598483579'] | [32300.0, 182572.0] | [72.0, 358.0] | [681, 741] |
p02684 | u733581231 | 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\nimport sys\nsys.setrecursionlimit(10**6)\nn , k = map(int , input().split())\narr = list(map(int , input().split()))\ndic = defaultdict(int)\nfor i in range(1,n+1):\n\tdic[i] = arr[i-1]\ncycle = []\nvisited = [False]*(10**6)\ncurr = 1\nif k <= n:\n\tcurr = 1\n\tcount = 0\n\twhile ... | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s168722722', 's568374566', 's950757199', 's484930875'] | [43832.0, 47300.0, 43820.0, 44088.0] | [200.0, 2207.0, 209.0, 227.0] | [748, 584, 795, 645] |
p02684 | u736470924 | 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 = list(map(int, input().split()))\n path = {}\n c = 1\n i = 1\n while c < k:\n if not i in path.keys():\n path[i] = c\n i = A[i - 1]\n c += 1\n elif i in path.keys():\n start = path[i]\n ... | ['Runtime Error', 'Accepted'] | ['s423721545', 's240698722'] | [32376.0, 32240.0] | [173.0, 139.0] | [462, 516] |
p02684 | u737135713 | 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... | ['z = 0\n\nb = [1]\nfor i in range(1000000):\n j = [a[b[i]-1]]\n b.extend(j)\n\nfor i in range(n):\n if b.count(i+1)>=3:\n z = z + 1\n\nif k <= n:\n y = b[k]\nelse:\n l = (k-n)%z\n y = b[n+l]\nprint(y)', 'a = list(map(int,input().split()))\nz = 0\nb = [1]\nc = [0]*n\nfor i in range(n*3):\n j = [a[b[i]-1]]\n ... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s353780002', 's502481193', 's739734465'] | [9124.0, 9224.0, 32300.0] | [25.0, 24.0, 606.0] | [192, 252, 282] |
p02684 | u745687363 | 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=[1]\ndef f(L):\n L.append(A[l[-1]]) if A[l[-1]] in L\nf(L)\nprint(L[k//len(L)])\n ', 'n, k = map(int, input().split())\nA = list(map(int, input().split()))\nL = [1]\ndef f(L):\n if A[L[-1]-1] not in L:\n L.append(A[L[-1]-1])\n r... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s842868514', 's959910501', 's986118918', 's195650994'] | [8920.0, 32380.0, 32360.0, 33380.0] | [24.0, 79.0, 79.0, 204.0] | [148, 318, 315, 279] |
p02684 | u748241164 | 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(int, input().split()))\n\ncheck = [0] * N\ntime = [-1] * N\ncheck[0] = 1\ntime[0] = 0\nnow = 1\nt = 1\nex = 0\nroop = 0\nfor i in range(N + 1):\n now = A[now - 1]\n if check[now - 1] == 0:\n check[now - 1] = 1\n time[now - 1] = t\n else:\n ex = time[now - 1... | ['Wrong Answer', 'Accepted'] | ['s265969035', 's251192089'] | [32304.0, 32224.0] | [197.0, 199.0] | [539, 567] |
p02684 | u750651325 | 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 re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): r... | ['Runtime Error', 'Accepted'] | ['s753095430', 's694747923'] | [34304.0, 34320.0] | [189.0, 189.0] | [970, 1048] |
p02684 | u751717561 | 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\nll = [a[0]]\n\nfor i in range(1, n):\n cnt = ll[i-1]\n if cnt = a[cnt-1]:\n print(cnt)\n exit()\n if a[cnt-1] == a[0]:\n break\n else:\n ll.append(a[cnt-1])\n\nprint(ll[k%3-1])\n', 'N, K = map(int, input(... | ['Runtime Error', 'Accepted'] | ['s165127720', 's036816312'] | [9020.0, 32368.0] | [26.0, 136.0] | [276, 368] |
p02684 | u751843916 | 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=[p-1 for p in a]\nl=[0]\ni=a[0]\np=-1\nq=-1\nfor x in range(n):\n if i in set(l):break\n l.append(i)\n i=a[i]\nd=-1\nfor x in range(n):\n if a[x]==i:\n d=x\n break\nf=l[:d]\nb=l[d:]\nprint(l,f,b,d)\nif len(f)==0 or len(b)==0:\... | ['Runtime Error', 'Accepted'] | ['s965250907', 's836117733'] | [32308.0, 32332.0] | [2206.0, 153.0] | [404, 456] |
p02684 | u756420279 | 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\nn, k = map(int, input().split())\nA = list(map(int, input().split()))\na = [0]*n\nb = A[0]\nper = []\ntes = -1\n\nif n >= k:\n for _ in range(k-1):\n b = A[b-1]\n print(b)\n exit()\n\n\nfor _ in range(k*2):\n #print(b)\n a[b-1] += 1\n tes += 1\n if 3 in a:\n ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s591980015', 's934517134', 's299273163'] | [32300.0, 32328.0, 32256.0] | [2206.0, 2206.0, 148.0] | [459, 427, 372] |
p02684 | u756607246 | 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\ndef main():\n N, K = map(int, input().split())\n As = list(map(int, input().split()))\n As = [0]+As\n ikisaki = As[1]\n aru = {1}\n itta = [1]\n imaitta = 1\n \n while not ikisaki in aru:\n imaitta = ikisaki\n ikisaki = As[ikisaki]\n itta.append(imaitta)\n aru.... | ['Runtime Error', 'Accepted'] | ['s822185241', 's143296127'] | [32232.0, 32348.0] | [176.0, 133.0] | [734, 703] |
p02684 | u760569096 | 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 = 0\nc = [0]\nif n < k:\n k = n\nfor i in range(k+2):\n b = a[b]-1\n if b in c:\n d = c.index(b)\n e = i-d+1\n k = k - len(c)+e\n c = c[-e:]\n print(c[k%e]+1)\n exit(0)\n else:\n c.append(b)\nprint(b+1)', 'NK = list(map... | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s128670270', 's811480229', 's844610353', 's909104402', 's356134661'] | [32312.0, 32364.0, 32252.0, 32372.0, 32344.0] | [2206.0, 155.0, 2206.0, 133.0, 133.0] | [284, 311, 390, 327, 264] |
p02684 | u764501786 | 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... | ["# 4 5 (4 cities and 5 steps)\n# 3 2 4 1\n\n# 1 => 3\n# 2 => 2\n# 3 => 4\n# 4 => 1\n\nN, K = map(int, input().split())\nA_i = list(map(int, input().split()))\n\npaths = {}\n\nfor i in range(N):\n paths[i+1] = A_i[i]\n\n# print('paths:', paths)\n\n# 6 5 2 5 3 2\n\n# 1 => 6 (1)\n# 6 => 2 (2)\n# 2 => 5 (3)\n# 5 => 3 (... | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s014002294', 's065250414', 's198087830', 's305382873', 's412641910', 's808508560', 's873929907', 's593839098'] | [48804.0, 48808.0, 48812.0, 48540.0, 48656.0, 48720.0, 48704.0, 48700.0] | [193.0, 2207.0, 206.0, 302.0, 291.0, 197.0, 201.0, 282.0] | [791, 1001, 951, 1249, 1258, 641, 616, 1255] |
p02684 | u768256617 | 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=[0]*n\ninfo=[1]\nnow=1\nwhile town[now-1]==0:\n town[now-1]+=1\n now=a[now-1]\n info.append(now)\nloop_list=list(info[info.index(now):-1])\nloop_len=len(loop_list)\nbefore_loop_list=list(info[:info.index(now)])\nprint(town)\nprint(info)\nif... | ['Wrong Answer', 'Accepted'] | ['s699264427', 's348006838'] | [32352.0, 32328.0] | [186.0, 172.0] | [425, 427] |
p02684 | u771167374 | 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... | ['#abc167c\nn, k = map(int, input().split())\na = [0] + list(map(int, input().split()))\n\nroot = [1]\nfor i in range(10**100):\n next_num = a[root[-1]]\n root.append(next_num)\n\nif k < n+1:\n print(root[k])\n exit()\n\nloop_end = n \nloop_start = n-1\nwhile(root[loop_start]!=root[loop_end]):\n loop_sta... | ['Time Limit Exceeded', 'Accepted'] | ['s687631342', 's237720435'] | [104652.0, 32256.0] | [2208.0, 190.0] | [398, 423] |
p02684 | u777068250 | 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 detectCycle(x, a):\n start,length = 0, 1\n p1, p2 = a[x], a[a[x]]\n while p1 != p2:\n p1, p2 = a[p1], a[a[p2]]\n\n p2 = x\n while p1 != p2:\n p1, p2 = a[p1], a[p2]\n start += 1\n\n p2 = a[p1]\n while p1 != p2:\n p2 = a[p2]\n length += 1\n \n return sta... | ['Wrong Answer', 'Accepted'] | ['s931771866', 's881027553'] | [32332.0, 32328.0] | [110.0, 225.0] | [553, 571] |
p02684 | u779728630 | 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 = tuple( map(int, input().split()) )\n\nL = [0 for i in range(N+1)]\nL[1] = 1\nx = 1\nt = 1\nwhile K>0:\n t += 1\n K -= 1\n x = A[x]\n if L[x] != 0:\n p = t - L[x]\n K %= p\n break\n else:\n L[x] = t\n \nwhile K>0:\n x = A[x]\n K -= 1\nprint(x)', 'N, K = map(i... | ['Runtime Error', 'Accepted'] | ['s550821797', 's194057841'] | [32408.0, 32404.0] | [127.0, 151.0] | [281, 286] |
p02684 | u785578220 | 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()))\ndp = [0] * (n+1)\nB = []\nf = 1\nc = 0\nfor e,i in enumerate(A,1):\n if dp[f-1] or i == 1:\n ans = e-dp[f-1]\n bal = dp[f-1]\n break\n else:\n dp[f-1]+=c\n B.append(A[f-1])\n f = A[f-1]\n c+=1\nk... | ['Runtime Error', 'Accepted'] | ['s586556046', 's666292605'] | [32136.0, 32236.0] | [216.0, 164.0] | [384, 304] |
p02684 | u788260274 | 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\nimport math\nfrom functools import reduce\nimport functools\nimport itertools\nfrom collections import deque\n\nn,k = [int(x) for x in stdin.readline().rstrip().split()]\na = [0] + [int(x) for x in stdin.readline().rstrip().split()]\n\nm = 0\nb = [1]\n\nc = 1\nfor i in range(n):\n ... | ['Wrong Answer', 'Accepted'] | ['s148877091', 's713947355'] | [32212.0, 32024.0] | [81.0, 139.0] | [534, 628] |
p02684 | u788703383 | 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 = [1] + a\ndef next(i):\n return a[i]\n\nz = [0] * (n+1)\n\nplace = 1\nT = 0\ninterval = 0\nif k < n:\n for i in range(k):\n place = next(place)\n print(place);exit()\nplace = 0\nfor i in range(n):\n place = next(place)\n if z[pl... | ['Runtime Error', 'Accepted'] | ['s925700425', 's362716661'] | [32380.0, 31064.0] | [166.0, 137.0] | [467, 566] |
p02684 | u789199177 | 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 \nnext_city = 1\nvisited = []\nx = [-1]*n\nwhile x[next_city-1] == -1:\n visited.append(next_city)\n next_city = A[next_city-1]\nidx = visited.index(next_city)\nvisited2 = visited[idx:]\nmod = len(visited2)\nx = (k%mod-idx)%mod\nprint(visit... | ['Time Limit Exceeded', 'Accepted'] | ['s376891621', 's157155319'] | [131620.0, 32284.0] | [2210.0, 176.0] | [312, 518] |
p02684 | u790710233 | 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 Counter\nsys.setrecursionlimit(10**7)\nn, k = map(int, input().split())\nA = list(map(lambda x: int(x)-1, input().split()))\n\n\nvisited = [0]*n\n\n\ndef dfs(v):\n if visited[v]+1 == 3:\n return 0\n visited[v] += 1\n dfs(A[v])\n\n\ndfs(0)\n\nc = Counter(visited)\nloop_cnt = c[2... | ['Runtime Error', 'Accepted'] | ['s692473192', 's764314394'] | [9416.0, 32284.0] | [24.0, 181.0] | [438, 390] |
p02684 | u792670114 | 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())\nAs = list(map(int, input().split()))\nAs = [A-1 for A in As]\nVs = [-1]*N\np = 0\np0 = -1\nRs = [p]\nVs[p] = p\nfor i in range(N):\n n = As[p]\n Rs.append(n)\n if not Vs[n] < 0:\n p0 = Vs[n]\n break\n p = n\n Vs[p] = p\n#print(Rs, p0)\nif K <= p0:\n r = Rs[K]\nelse:\n r ... | ['Runtime Error', 'Accepted'] | ['s442421004', 's764402236'] | [32312.0, 32376.0] | [178.0, 151.0] | [340, 342] |
p02684 | u793666115 | 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()))\nfrom collections import deque\n\nans = deque()\nans.appendleft(1)\ncount = 1\ns = -1\n\nwhile True:\n if a[count-1] in a[:count-1]:\n s = a[count-1]\n ans = a[:count-1]\n break\n else:\n count = a[count-1]\n\nif s =... | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s534415175', 's682758744', 's966809521', 's009792100'] | [32384.0, 88124.0, 32380.0, 32376.0] | [2206.0, 2208.0, 2206.0, 179.0] | [461, 513, 459, 515] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.