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 |
|---|---|---|---|---|---|---|---|---|---|---|
p02683 | u968649733 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and r... | ['#N, M, X = [int(n) for n in input().split()]\n\n#CA = [list(map(int, input().split())) for n in range(N)]\n\n#print(N,M,X)\n#print(CA)\n\nmin_cost = 12*10**5\n\n\ndef dfs(CA, cost, skills, cur, used, min_cost):\n #Pdb().set_trace()\n #print(cur)\n skills = [skills[i] + n for i, n in enumerate(CA[cur][1:])]\n used... | ['Runtime Error', 'Accepted'] | ['s860758034', 's133292758'] | [9168.0, 9228.0] | [25.0, 87.0] | [829, 468] |
p02683 | u970082363 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and r... | ['n,k,x = (int(x) for x in input().split())\nC = []\nA = []\nfor i in range(n):\n list = [int(i) for i in input().split()]\n C.append(list[0])\n A.append(list[1:])\ni = 0\ncase = [0]*(2**n)\nchk = []\nfor i in range(2**n):\n chk.append([0]*m)\ni = 0\nfor i in range(2 ** n):\n for j in range(n): \n ... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s386204895', 's906795015', 's910935060', 's642935943'] | [9272.0, 9284.0, 9208.0, 11228.0] | [24.0, 26.0, 21.0, 97.0] | [764, 741, 636, 654] |
p02683 | u970267139 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and r... | ["n, m, x = map(int, input().split())\nbook = [list(map(int, input().split())) for _ in range(n)]\nchoose = 1\ncost_min = 1000000 * n\nfor i in range(2 ** n - 1):\n a_list = [0] * (m + 1)\n c = bin(choose)[2:].zfill(n)\n for j in range(n):\n if c[n - j - 1] == '1':\n a_list = [x + y for (x, y... | ['Wrong Answer', 'Accepted'] | ['s972936298', 's992059394'] | [9172.0, 9172.0] | [64.0, 62.0] | [516, 543] |
p02683 | u972658925 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and r... | ['n,m,x = map(int,input().split())\n\nlst = []\nfor _ in range(n):\n lst.append(list(map(int,input().split())))\n\nlst.sort(key=lambda x: sum(x[1:]) ,reverse=True)\n\nrikaido = [0]*m\nrikaido_check1 = [0]*m\n\nrikaido2 = [0]*m\nrikaido_check2 = [0]*m\n\nans1 = 0\nans2 = 0\n\ncheck1 = 0\nfor i in lst:\n for j in r... | ['Wrong Answer', 'Accepted'] | ['s947443830', 's568371284'] | [9272.0, 9224.0] | [22.0, 73.0] | [821, 763] |
p02683 | u975445930 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and r... | ["n,m,x = map(int, input().split())\nl = [list(map(int, input().split())) for i in range(n)]\nans = float('inf')\n\nfor i in range(2**n):\n sum = [0]*(M+1)\n \n for j in range(n):\n \n if ((i >> j) & 1):\n for k in range(M+1):\n sum[k] += l[j][k]\n if sum[0] < ans:\n ... | ['Runtime Error', 'Accepted'] | ['s387222472', 's107054605'] | [9228.0, 9180.0] | [25.0, 85.0] | [547, 537] |
p02683 | u981418135 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and r... | ['n,m,x = map(int, input().split())\nc_a = []\nfor i in range(n):\n c_a.append(list(map(int, input().split())))\n\nmin_sum_answer = 0\nfor i in range(n**2):\n min_sum = 0\n get_score = []\n for m in range(m):\n get_score.append(0) \n for j in range(n):\n if i >> j % 2 ==1:\... | ['Runtime Error', 'Accepted'] | ['s036184621', 's738101284'] | [9036.0, 9020.0] | [28.0, 100.0] | [837, 905] |
p02683 | u988661952 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and r... | ['import itertools\nimport numpy as np\nN,M,X=map(int,input().split())\nlista=[]\nfor i in range(N):\n lista.append(list(map(int,input().split())))\nlista=np.array(lista)\ncost=1000000000000000\njudge=[X]*M\ndata=[k for k in range(1,N+1)]\nfor i in range(1,N+1):\n a=list(itertools.combinations(data,i))\n for j... | ['Runtime Error', 'Accepted'] | ['s789665929', 's066176045'] | [27680.0, 27684.0] | [147.0, 146.0] | [564, 602] |
p02683 | u989345508 | 2,000 | 1,048,576 | Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0. Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and r... | ['import itertools\n\nN, M, X = list(map(int, input().split()))\na = [list( map( int, input().split() ) ) for i in range(N)]\n\nfor x in itertools.product([0,1], repeat=2):\n cost = 0\n level = [] * M\n judge = True\n ans = 1234567\n for i in range(N):\n if a[i] == 1:\n cost += a[i][0]\n level = [y + ... | ['Runtime Error', 'Accepted'] | ['s068162644', 's002929034'] | [9208.0, 9100.0] | [25.0, 85.0] | [515, 479] |
p02684 | u010090035 | 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()))\nroop=[]\n\na.insert(0, 0)\ns=1\nfor i in range(k):\n s=a[s]\n if(s not in roop):\n roop.append(s)\n else:\n s_first=roop.index(s)\n roop=roop[s_first:]\n k-=(s_first+1)\n# print(k,roop,s_first)\n# print(... | ['Wrong Answer', 'Accepted'] | ['s694060659', 's849471397'] | [32380.0, 32276.0] | [2206.0, 149.0] | [336, 425] |
p02684 | u010870870 | 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())\ntele = list(map(int,input().split()))\nk = 1\ngoal = tele[0]\nmiti = [1]\nwhile (goal in miti)!=1:\n k += 1\n miti.append(goal)\n goal = tele[goal-1]\n if k == K:\n goal = tele[goal-1]\n print(goal)\n sys.exit()\nprint(miti)\n\na = miti.inde... | ['Wrong Answer', 'Accepted'] | ['s441597903', 's508742786'] | [32244.0, 32380.0] | [2206.0, 173.0] | [358, 351] |
p02684 | u013513417 | 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\n\n\nS = [0]*N\nL = []\nS[0]=1\nL.append(1)\ncount=1\npos=A[0]\n\n\nif A[0]==0:\n print(1)\n exit()\n\nfor i in range(N+1):\n \n if S[pos]==0:\n count+=1\n S[pos]=count\n L.append(pos+1)\n ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s071731882', 's086336658', 's526702966'] | [32480.0, 38668.0, 33868.0] | [218.0, 225.0, 201.0] | [587, 714, 706] |
p02684 | u014800961 | 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())\nalist = list(map(int,input().split()))\n\ntown_loop = [1]\nused = [-1] * n\n\nfor i in range(k):\n next_town = alist[town_loop[i]-1]\n\n if used[next_town-1] == -1:\n town_loop.append(next_town)\n used[next_town-1] = 1\n break\n else:\n break\n\nl... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s083837647', 's897705257', 's929752939'] | [32276.0, 32380.0, 32308.0] | [71.0, 2206.0, 165.0] | [488, 427, 474] |
p02684 | u014958112 | 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())\na = list(map(int, input().split()))\nb = []\ncnt = 0\nnext_town = 0\n\nl = len(a) + 1\nfor j in range(l):\n if j==0:\n b.append(a[0])\n next_town = a[0]\n continue\n \n b.append(a[next_town - 1])\n next_town = a[next_town -1]\nprint(b)\nfo... | ['Wrong Answer', 'Accepted'] | ['s011296582', 's683409328'] | [32384.0, 32268.0] | [2206.0, 134.0] | [612, 425] |
p02684 | u015593272 | 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 import sys\n input = sys.stdin.readline\n\n N_ko, K_kai = map(int, input().split())\n \n teleport = list(map(int, input().split()))\n\n index = 0\n ctr = 0\n before_ctr = 0\n\n Visited = []\n Visited.append(ctr)\n\n for i in range(N_ko + 1):\n\n ctr += 1\n ... | ['Wrong Answer', 'Accepted'] | ['s287842724', 's138090924'] | [31268.0, 33384.0] | [2206.0, 158.0] | [1341, 787] |
p02684 | u017415492 | 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\nsa=set()\nd=dict()\ncount=0\nniko=0\nanss=0\nbx=False\nwhile True:\n count+=1\n if count+1==k:\n anss=a[s]\n bx=True\n print(a[s])\n count-1\n break\n if not (a[s-1] in sa):\n sa.add(a[s-1])\n d[a[s-1]]=count\n s=a[s-1]\n ... | ['Wrong Answer', 'Accepted'] | ['s332638413', 's910374017'] | [40724.0, 40796.0] | [239.0, 211.0] | [569, 571] |
p02684 | u018168283 | 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())\niran=[]\nl=list(map(int,input().split()))\n#n,k=6,727202214173249351\n#l=[6,5,2,5,3,2]\nfor i in range(N):\n if l.count(i+1)==0:\n iran.append(i+1)\nkiseki=[]\n\nu=1\nkiseki.append(1)\nfor i in l:\n u=l[u-1]\n if kiseki.count(u)==0:\n kiseki.append(u)\n else:\n kiseki.append... | ['Runtime Error', 'Accepted'] | ['s922789594', 's122456180'] | [32316.0, 32384.0] | [69.0, 150.0] | [513, 282] |
p02684 | u020962106 | 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()))\nrep = []\nrep.append(1)\ni = 0\ncnt = 0\nif n>k:\n end =k\nelse:\n end =n\nnof = 0\nwhile True:\n cnt+=1\n if cnt>end:\n nof=1\n break\n go = a[i]-1\n if a[i] not in rep:\n rep.append(a[i])\n i = go\n el... | ['Wrong Answer', 'Accepted'] | ['s663651072', 's587810272'] | [32376.0, 32744.0] | [2206.0, 208.0] | [724, 362] |
p02684 | u023185908 | 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()))\nimport numpy as np\nlink = set()\nnext = a[0]\nlink.add(1)\nwhile next not in link:\n link.add(next)\n next = a[next-1]\nprint(next)\n# print(link)\n\nlink2 = set()\nnext2 = a[0]\nlink2.add(1)\nwhile next not in link2:\n link2.add(next2)\n... | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s682373861', 's694019199', 's953051426', 's095821194'] | [57500.0, 57824.0, 57824.0, 57772.0] | [375.0, 334.0, 342.0, 346.0] | [879, 660, 549, 784] |
p02684 | u024340351 | 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 \nB = []\nVector = [0]*N\nj = 0\n \nfor i in range (0,K+1):\n\tif Vector(A[j]) == 1:\n\t\tValue = B.index(A[j])\n\t\tC = B[B.index(A[j])::]\n\t\tbreak\n\telse:\n\t\tB.append(A[j])\n\t\tVector(A[j]) = 1\n\t\tj = A[j]-1\n\nif A[0] ==1:\n\tprint(1)\... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s166620571', 's420151493', 's204542754'] | [9156.0, 32224.0, 32244.0] | [24.0, 133.0, 151.0] | [352, 352, 354] |
p02684 | u024768467 | 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] + list(map(int,input().split()))\n\ntown_num_tmp = 1 \nseen = [-1]*(n+1) \ntown_hist_list = []\n\nwhile seen[town_num_tmp] == -1:\n seen[town_num_tmp] = 1\n town_hist_list.append(town_num_tmp)\n \n town_num_tmp = a_list[town_num_tmp]\n\nroop_end = len(town_his... | ['Wrong Answer', 'Accepted'] | ['s456833077', 's412930978'] | [32268.0, 32292.0] | [164.0, 172.0] | [613, 661] |
p02684 | u025463382 | 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()]\ncounter = 1\ncur = 0\nmem = [0]\nwhile True:\n if counter == k:\n ans = cur +1\n break\n cur = a[cur]\n mem.append(cur)\n counter += 1\n if cur == 0:\n k = k%counter\n ans = mem[k]\n break\nprint(ans)', 'n,k = ... | ['Wrong Answer', 'Accepted'] | ['s318611920', 's820383727'] | [101816.0, 32328.0] | [2208.0, 153.0] | [292, 514] |
p02684 | u031157253 | 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\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n A.insert(0, 0)\n J = [-1] * (N + 1)\n T = []\n que = deque([1])\n count = 0\n l = 0\n while que:\n i = que.popleft()\n if J[i] != -1:\n l = J[i]\n ... | ['Wrong Answer', 'Accepted'] | ['s633484486', 's644719420'] | [33920.0, 33808.0] | [169.0, 164.0] | [501, 502] |
p02684 | u033272694 | 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())\nlist1 = list(map(int,input().split()))\nvisited_town = [[] for i in range(N+1)] \nvisited_time = [None for i in range(2*N)] \n\nvisited_town[1].append(0) \nvisited_time[0] = 1\n\ncycle_start = -1\ncycle_end = -1\ncycle_detect = False\n\nfor i in range(1,min([K,2*N])):\n next_town = li... | ['Runtime Error', 'Accepted'] | ['s774001442', 's708364316'] | [9092.0, 48372.0] | [25.0, 310.0] | [890, 815] |
p02684 | u036065030 | 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 check_num_of_remaining_teleport(num_of_teleport, i):\n if num_of_teleport == 0:\n print(i)\n exit()\n\nnum_of_town, num_of_teleport = map(int, input().split())\ntown = np.array(list(map(int, input().split())))\n\n\ni = 1\n\nfragranttown_index = 1\nfragrants = [0] * num_of_to... | ['Wrong Answer', 'Accepted'] | ['s983003826', 's077990775'] | [50948.0, 50936.0] | [510.0, 412.0] | [1534, 1408] |
p02684 | u036104576 | 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 itertools\nimport numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n \nN, K = map(int, readline().split())\nA = list(map(lambda x: x - 1, map(int, readline().split())))\nvisited = [False for i in range(N)]\n\ncur = 0\ncycle = ... | ['Wrong Answer', 'Accepted'] | ['s925754387', 's574544852'] | [47276.0, 46316.0] | [310.0, 251.0] | [762, 764] |
p02684 | u038724782 | 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_l = list(map(int,input().split()))\n\ntown = 1\ncount = 0\ntown_visited = set()\nwhile count < k:\n town_visited.add(town)\n town = a_l[town-1]\n count += 1\n if town in town_visited:\n break\n\nk -= count\nif k = 0:\n print(town)\n exit()\ncount = 0\ntown_v... | ['Runtime Error', 'Accepted'] | ['s693219077', 's521898248'] | [9040.0, 32404.0] | [25.0, 165.0] | [543, 544] |
p02684 | u042113240 | 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 for j in range(N)]\nX[0] = 0\nY = [0]\ni = 0\nNum = 0\nMM = 0\nfor k in range(1,N):\n i = A[i]-1\n if k == K:\n MM = 1\n P = i\n elif X[i] != -1:\n Num = X[i]\n break\n else:\n X[i] = k\n Y.append(i)\nY = Y[Num:]\nB = (... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s659344235', 's980078166', 's576706382'] | [9104.0, 9048.0, 32248.0] | [23.0, 23.0, 172.0] | [357, 356, 368] |
p02684 | u048176319 | 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())\nla = list(map(int, input().split()))\n\nlc = [1]\nlcnt = [1]\nlcnt.extend([0]*(N-1))\nprint(lcnt)\ni = 1\nwhile lcnt[lc[i-1]-1] == 1:\n if i == N:\n break\n else:\n lc.append(la[lc[i-1]-1])\n lcnt[la[lc[i-1]-1]-1] += 1\n i += 1\nprint("lcnt =", lcnt)... | ['Wrong Answer', 'Accepted'] | ['s127857828', 's491635007'] | [32384.0, 32112.0] | [286.0, 212.0] | [519, 450] |
p02684 | u048800107 | 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 = sys.stdin.readline\ndef main():\n n,k = map(int,input().split())\n l = list(map(int,input().split()))\n position = 1\n\n town = ''\n stayed = [1]+[0]*n\n stayed_c = [0]*n\n for i in range(n):\n position = l[position-1]\n if not position in stayed:\n st... | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s235325974', 's666000772', 's686363640', 's804323515', 's484470621'] | [9084.0, 32276.0, 32300.0, 32304.0, 31372.0] | [23.0, 2206.0, 2206.0, 2206.0, 139.0] | [633, 493, 433, 473, 659] |
p02684 | u048915776 | 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(input().split())\np[0]=int(a[0])-1\nf=0\nfor i in range(k-1):\n p[i+1]=int(a[p])-1\n for j in range(i+1):\n if p[i+1] == p[j]:\n r=j\n q=j-i-1\n f=1\n break\n if f==1:\n break\nk-=r\nk%=q\ns=p[r+k-1]\nif f==0: \... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s432486471', 's657431008', 's390664606'] | [25664.0, 34000.0, 36324.0] | [48.0, 144.0, 190.0] | [339, 371, 403] |
p02684 | u051358943 | 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\n\ndef solve():\n N, K = map(int,input().split())\n A = list(map(int, input().split()))\n\n state = 1\n chklist = [0] * (N + 1)\n chklist_flag = [False] * (N + 1)\n chkmod = 0\n\n chklist_flag[0] = True\n\n for i in range(1, K + 1):\n print(chklist)\n state = A[state ... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s116079823', 's564165028', 's133045464'] | [149044.0, 150284.0, 32252.0] | [2445.0, 972.0, 166.0] | [643, 663, 688] |
p02684 | u054556734 | 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\ndef bin(arr,val):\n left,right = 0,len(arr)-1\n while left<=right:\n mid = (left+right)//2\n if arr[mid]==val: return 1\n elif arr[mid]<val: left = mid + 1\n else: right = mid - 1\n return 0\n\nknow = []\nno... | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s456413532', 's532389372', 's743106666', 's678081362'] | [32284.0, 9080.0, 9012.0, 32388.0] | [818.0, 27.0, 23.0, 725.0] | [597, 600, 599, 598] |
p02684 | u060938295 | 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"""\nCreated on Sun May 10 20:50:56 2020\n"""\n\nimport sys\n#import numpy as np\n\nsys.setrecursionlimit(10 ** 9)\n#def input():\n# return sys.stdin.readline()[:-1]\nmod = 10**9+7\n\n#N = int(input())\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\ncity = [False for... | ['Runtime Error', 'Accepted'] | ['s084426201', 's372002968'] | [146948.0, 32276.0] | [1896.0, 196.0] | [762, 764] |
p02684 | u067986021 | 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(' ')]\nA = [0]\nA.extend([int(a) for a in input().split(' ')])\ncheck_list = [0] * (N + 1)\n\ntown = 1\ncheck_point = 0\ninitial = -1\ninterval = -1\n\nprint(A)\n\nfor k in range(K):\n if check_list[town] > 0:\n check_point = town\n initial = check_list[town]\n ... | ['Wrong Answer', 'Accepted'] | ['s383372812', 's942571865'] | [148916.0, 32200.0] | [2818.0, 198.0] | [657, 614] |
p02684 | u078816252 | 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()))\nans = 1\nn = 1\ncheck = 1\ncity = [-1 for i in range(N+1)]\ncity[1] = 0\nroop = 1\ni = 0\nwhile(check == 1):\n if i == K:\n check = 0\n else:\n n = A[n]\n i = i + 1 \n if city[n] == -1:\n city[n] = i\n else:\n roop = ... | ['Wrong Answer', 'Accepted'] | ['s247886577', 's365324304'] | [32356.0, 32372.0] | [138.0, 147.0] | [403, 397] |
p02684 | u084865106 | 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\n t = 1\n ans = [1]\n for i in range(n):\n if a[t-1] in ans :\n start = ans.index(a[t-1])\n break\n ans.append(a[t-1])\n t = a[t-1]\n\n index = k % (len(ans)-start)\n ... | ['Wrong Answer', 'Accepted'] | ['s750951623', 's025527796'] | [32188.0, 32336.0] | [2206.0, 109.0] | [369, 393] |
p02684 | u090361088 | 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... | ['Town = []\nC = 0\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ndef dfs(a, i, town, c):\n if i-1 in town:\n L = len(town) - len(town[:town.index(i-1)])\n c += (K - c) - (K%L)\n town = []\n town.append(i-1)\n else:\n town.append(i-1)\n c += 1\n ... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s679146875', 's927191568', 's906711907'] | [32332.0, 32380.0, 32364.0] | [83.0, 144.0, 150.0] | [406, 272, 275] |
p02684 | u090649502 | 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\n\n# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools\ndef main(n, k, a):\n ck=[-1]*n\n tak=0\n c=0\n ck[0]=c\n for i in range(n):\n c+=1\n tak=a[tak]-1\n if ck[tak]!=-1:\n loop=c-ck[tak]\n lps=ck[tak]\n bre... | ['Wrong Answer', 'Accepted'] | ['s450947352', 's975671665'] | [32364.0, 32312.0] | [218.0, 169.0] | [558, 541] |
p02684 | u091489347 | 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())\nl = list(map(int, input().split()))\ncount = 0\nli = [0 for _ in range(n)]\nb = 1\nfor i in range(1,n + 1):\n print(b)\n if li[b-1] != 0:\n break\n li[b-1] = i\n b = l[b-1]\n count += 1\n# print('count',count)\n\n\nd = count - li[b-1] + 1\ninterc... | ['Wrong Answer', 'Accepted'] | ['s319346380', 's437808300'] | [32392.0, 32332.0] | [302.0, 182.0] | [559, 565] |
p02684 | u095094246 | 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())\na=[int(x) for x in input().split()]\nvis={0:0}\nnow=0\nfor i in range(1,k+1):\n now=a[now]-1\n if now in vis:\n bgn=vis.index(now)\n print(vis[bgn+((k-bgn)%(len(vis)-bgn))]+1)\n sys.exit()\n else:\n vis[i]=now\nprint(vis[-1]+1)\n', 'import sys\nn,k=map(int,inpu... | ['Runtime Error', 'Accepted'] | ['s318437372', 's280880881'] | [33432.0, 32332.0] | [102.0, 148.0] | [272, 300] |
p02684 | u102218630 | 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\ngenzaichi=1\ncount=0\nfor i in range(K):\n genzaichi=A[genzaichi-1]\n count += 1\n if genzaichi == 1:\n break\n\nK=K%count\nprint(count)\n\nfor i in range(K):\n genzaichi=A[genzaichi-1]\n\n\nprint(genzaichi)', 'N,K=map(int,input().sp... | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s011673534', 's687787683', 's688430168', 's927862888'] | [32272.0, 32396.0, 32380.0, 36136.0] | [2206.0, 2206.0, 68.0, 167.0] | [274, 566, 541, 538] |
p02684 | u102367647 | 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 math\n\n\ndef main():\n n, k = list(map(int, input().split()))\n A = list(map(int, stdin.readline().split()))\n roots = []\n roots.append(A)\n maxLoop = math.ceil(math.log(k)/math.log(2))\n for _ in range(1, maxLoop):\n roots_tmp = [None] * n\n for j in ra... | ['Runtime Error', 'Accepted'] | ['s932181638', 's170003627'] | [110476.0, 31328.0] | [2209.0, 154.0] | [590, 517] |
p02684 | u105302073 | 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... | ['6 727202214173249351\n6 5 2 5 3 2\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\ns = []\no = [-1] * (n + 1) \nc, l = 1, 0 \n\nv = 1\nwhile o[v] == -1:\n o[v] = len(s)\n s.append(v)\n v = a[v-1]\nc = len(s) - o[v]\nl = o[v]\n\nif k < l:\n print(s[k])\nelse:\n k -= l\... | ['Runtime Error', 'Accepted'] | ['s481199806', 's401443643'] | [9012.0, 32336.0] | [24.0, 168.0] | [402, 369] |
p02684 | u112114596 | 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\nloopcount=0\ntmpPoint=1\nvis={1:0}\nfor i in range(N):\n Next=A[tmpPoint-1]\n if Next in vis:\n startat=i\n #print(startat)\n #print(tmpPoint)\n #print(vis)\n #print(Next)\n #print(vis[Next]+1)\n ... | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s654829406', 's878449014', 's886419443', 's894043829', 's862590476'] | [38836.0, 38920.0, 38820.0, 38816.0, 38652.0] | [260.0, 250.0, 191.0, 193.0, 209.0] | [625, 608, 590, 587, 598] |
p02684 | u112629957 | 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())\nls_pass = list(map(int,input().split()))\nls_pass.insert(0,0)\na=1\nb=0\nls_past=[1]\nfor i in range(1,N+1):\n b=a\n a=ls_pass[a]\n if b==a:\n print(a)\n break\n elif a in ls_past:\n c=ls_past.index(a)\n ls_cicle=ls_past[c:i]\n print(ls_cicle[(K-i)%(i-c)])\n brea... | ['Runtime Error', 'Accepted'] | ['s953377179', 's766951067'] | [9028.0, 32388.0] | [25.0, 145.0] | [368, 359] |
p02684 | u114641312 | 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 math import factorial,sqrt,ceil,gcd\n# from itertools import permutations,combinations,combinations_with_replacement\n# from collections import deque,Counter\n# import re\n\n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\n# import numpy as np\n# import networkx as nx\n# from sci... | ['Wrong Answer', 'Accepted'] | ['s228353571', 's907476543'] | [40044.0, 32376.0] | [210.0, 182.0] | [1400, 1508] |
p02684 | u116038906 | 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... | ['\nfrom collections import Counter\nfrom copy import deepcopy\nimport sys\ninput = sys.stdin.readline\nN,K = (int(x) for x in input().split())\nA = list(map(int, input().split()))\nconnection ={}\nfor i,v in enumerate(A):\n connection[i+1] =v \n\n\npassed=[1]\nnex =connection[1]\nlap =[]\nlap_num =0\npass_set =set(... | ['Runtime Error', 'Accepted'] | ['s655325823', 's794268662'] | [49864.0, 49268.0] | [254.0, 282.0] | [747, 924] |
p02684 | u118887775 | 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 parse():\n N, K = map(int, input().split(" "))\n A = []\n for a in input().split(" "):\n A.append(int(a) - 1)\n return N, K, A\n\ndef fast_mod(x, N):\n return (x * N) >> 32\n\ndef main():\n N, K, A = parse()\n # print(N, K, A)\n\n \n route = []\n next_town = A[0]\n town = 0\n while not (next_town... | ['Runtime Error', 'Accepted'] | ['s012940021', 's329817513'] | [32224.0, 32288.0] | [2206.0, 136.0] | [894, 2087] |
p02684 | u119982001 | 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# a = list(map(int, input().split()))\n\nD = 60\nMAX_N = 200005\nto[D][MAX_N]\n\nfor i in range(n):\n to[0][i] = int(input())\n to[0][i] -= 1\n\nfor i in range(i, D-1):\n for j in range(n):\n to[i+1][j] = to[i][to[i][j]]\n\nv = 0\nfor i in range(D-1,0):\n l = 1<<i\n... | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s033295822', 's547845283', 's900218225', 's357728104'] | [9208.0, 32380.0, 32372.0, 32296.0] | [23.0, 2206.0, 109.0, 158.0] | [365, 415, 144, 293] |
p02684 | u123872895 | 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 collections\n\nn, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nh = []\ni = 0\ns = 1\n\nans = 0\nwhile i < 2*n: \n g = a[s-1]\n h.append(g)\n if i == k - 1:\n ans = g\n sys.exit()\n else:\n s = g\n i+=1\nj = collections.Counter(h)\nm = j.most_common()[0][0]\nl = [i... | ['Runtime Error', 'Accepted'] | ['s147178543', 's817999739'] | [39240.0, 32380.0] | [373.0, 173.0] | [399, 423] |
p02684 | u126146165 | 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\nG = {}\nfor i in range(1, n + 1):\n G.update({i: a[i - 1]})\n\nseen = [False] * (n + 1)\npath = []\n\ndef dfs(graph, start):\n global return_ans\n seen[start] = True\n path.append(start)\n \n if seen[graph[start]]:\n retu... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s768562071', 's916263263', 's967307512'] | [38840.0, 39988.0, 40556.0] | [145.0, 145.0, 231.0] | [512, 508, 410] |
p02684 | u127873832 | 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()))\nroute = [1]\ndest = A[0]\nwhile dest not in route:\n route.append(dest)\n dest = A[dest - 1]\nind = route.index(dest)\ncycle = route[ind:]\nprint(ind, cycle)\nif k >= ind:\n ans = (k - ind) % len(cycle)\n print(cycle[ans])\nelse:\n ... | ['Wrong Answer', 'Accepted'] | ['s290721496', 's153543035'] | [32376.0, 40704.0] | [2206.0, 208.0] | [319, 367] |
p02684 | u130387509 | 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\n\ns = []\nord = [-1] * (n+1)\n\nv = 1\nc = 1\nl = 0\nwhile ord[v] == -1:\n ord[v] = len(s)\n s.append(v)\n v = a[v-1]\nc = len(s) - ord[v]\nl = ord[v]\n\nprint(s)\nprint(l+k)\nif l > k:\n print(s[k])\nelse:\n k -= l\n k %= c\n ... | ['Wrong Answer', 'Accepted'] | ['s032135097', 's821660355'] | [32244.0, 32376.0] | [166.0, 170.0] | [313, 513] |
p02684 | u130900604 | 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# Your code here!\n# from collections import Counter\n# from functools import *\n\ndef LI():\n return list(map(int,input().split()))\n\nn,k=LI()\na=[q-1 for q in LI()]\n\nvisited=[-1]*n\nnow=0\nvisited[now]=0\n\nif k<=2*10**5:\n for i in range(k):\n nxt=a[now]\n now=nxt\n print... | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s004299631', 's094029288', 's348166166', 's540663181', 's848414512', 's605646596'] | [32380.0, 32380.0, 31788.0, 32272.0, 31808.0, 31812.0] | [196.0, 123.0, 167.0, 148.0, 152.0, 157.0] | [535, 522, 346, 422, 399, 396] |
p02684 | u131638468 | 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\nvisit=[False for i in range(n)]\nvisit[0]=True\nlooplist=[False for i in range(n)]\nmark=-1\ni=0\nnum=0\nloop=0\ncount=0\nwhile True:\n num+=1\n i=a[i]\n if mark<0 and visit[i]:\n mark=a[i]\n else:\n visit[i]=True... | ['Wrong Answer', 'Accepted'] | ['s836345020', 's933790157'] | [32240.0, 32408.0] | [309.0, 319.0] | [536, 520] |
p02684 | u133936772 | 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... | ['f=lambda:map(int,input().split())\nn,k=f()\na=list(f())\nlv=[-1]*n\nlv[0]=0\np=0\nfor i in range(n):\n t=a[p]-1\n if lv[t]>=0:\n l,r=lv[t],i+1\n break\n lv[t]=i+1\n p=t\nprint(lv,l,r)\nd,m=divmod(k-l,r-l)\nprint(d,m)\nprint(lv.index(l+(k-l)%(r-l) if k>l else k)+1)', 'n,k,*a=map(int,open(0).read().split())\n... | ['Wrong Answer', 'Accepted'] | ['s412088352', 's593864823'] | [32376.0, 31776.0] | [210.0, 142.0] | [258, 137] |
p02684 | u135961419 | 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 \nposition = 1\nexp = [1]\ncount = 0\n \nif n >= k:\n for i in range(k):\n position = a[position - 1]\n print(position)\nelse:\n for i in range(k):\n position = a[position - 1]\n count += 1\n if position in exp:\n exp.appe... | ['Runtime Error', 'Accepted'] | ['s921376131', 's864888420'] | [99740.0, 32244.0] | [2209.0, 143.0] | [426, 491] |
p02684 | u139940813 | 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())\n\nA = [int(i) for i in input().split()]\n\n\ndef has_duplicates(seq):\n return len(seq) == len(set(seq))\n\n\nwarp = [1]\na = 1\n\n\nwhile has_duplicates(warp):\n a = A [a - 1]\n warp.append(a)\n \n if len(warp) == K +1:\n print(warp[K])\n break\n\nl = [i ... | ['Runtime Error', 'Accepted'] | ['s765829373', 's061231935'] | [33120.0, 32340.0] | [2206.0, 164.0] | [713, 532] |
p02684 | u143212659 | 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 python\n# -*- coding: utf-8 -*-\n\n\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n\n R = [False] * (N + 1)\n D = []\n\n p = 1\n\n while True:\n if R[p]:\n break\n D.append(p)\n R[p] = True\n p = A[p - 1]\n... | ['Runtime Error', 'Accepted'] | ['s669353976', 's734861200'] | [32248.0, 32388.0] | [110.0, 135.0] | [456, 458] |
p02684 | u146307964 | 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())\nAlist = list(map(int, input().split()))\n\n\nloop_num = 2 * 10 ** 5\nloop_start_point = -1\npoint = 1\ncount_list = [-1] * N\n\nfor i in range(K):\n #print("point:", point)\n count_list[point - 1] = i\n nextPoint = Alist[point - 1]\n\n if count_list[nextPoint - 1] != -1:\... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s845543403', 's942222907', 's705336719'] | [9056.0, 32372.0, 32292.0] | [24.0, 145.0, 134.0] | [802, 480, 801] |
p02684 | u155687575 | 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 lst = list(map(int, input().split()))\n ma = [l-1 for l in lst]\n \n visited = [False for _ in range(n)]\n history = []\n now = 0\n while True:\n if visited[now]:\n history.append(now)\n break\n \n visi... | ['Wrong Answer', 'Accepted'] | ['s430426775', 's341757664'] | [32372.0, 32380.0] | [136.0, 142.0] | [790, 789] |
p02684 | u163320134 | 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())\narr=list(map(int,input().split()))\nl=[-1]*(n+1)\ntmp=[]\npos=1\ncnt=0\nwhile 1:\n if l[pos]!=-1:\n if k<=l[pos]:\n print(tmp[k])\n else:\n print(tmp[l[pos]+(k+1)%(cnt-l[pos])])\n break\n l[pos]=cnt\n cnt+=1\n tmp.append(pos)\n pos=arr[pos-1]', 'n,k=map(int,input(... | ['Wrong Answer', 'Accepted'] | ['s538144776', 's070648645'] | [32360.0, 32380.0] | [180.0, 174.0] | [280, 284] |
p02684 | u163501259 | 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 = sys.stdin.readline\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n flag = True\n D = 0\n now = 1\n LOG = {}\n PATH = []\n for i in range(N):\n PATH.append(D)\n LOG.setdefault(D,i)\n\n if LOG[D] == i:\n ... | ['Runtime Error', 'Accepted'] | ['s969047521', 's839857023'] | [45512.0, 40008.0] | [178.0, 157.0] | [542, 595] |
p02684 | u164471280 | 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\ndef subtraction(x):\n return x - 1\nA = list(map(subtraction, A))\n\n\nR = [0]*n\nR[0] = 1\nROUTE = [0]\nt = A[0]\nwhile R[t] == 0:\n ROUTE.append(t)\n R[t] = 1\n t = A[t]\n print(ROUTE, R, t)\n\nx = ROUTE.index(t) \nlength = len... | ['Wrong Answer', 'Accepted'] | ['s619885952', 's709120724'] | [139828.0, 32276.0] | [2477.0, 162.0] | [555, 511] |
p02684 | u165436807 | 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()))\nt = [1]\nx = [0]*n\nx[0] = 1\ny = 1\nz = 0\nd = 0\nfor i in range(k):\n t.append(a[t[i]-1])\n if x[a[t[i]-1]-1] != 0:\n y = x[a[t[i]-1]-1]\n z = i+2\n b = [a[t[i]-1]]\n break\n else:\n x[a[t[i]-1]-1] += i... | ['Runtime Error', 'Accepted'] | ['s037516469', 's887479454'] | [32328.0, 32412.0] | [250.0, 243.0] | [480, 564] |
p02684 | u166340293 | 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()))\nflag=0\nnow=0\ni=0\ncount=0\nc=[0]*N\nr=[0]\nc[0]=1\nwhile flag==0:\n now=A[now]-1\n count+=1\n if count==K:\n flag=1\n elif c[now]==1:\n flag=2\n c[now]=1\n r.append(now)\nif flag==1:\n print(now+1)\nelse:\n o=[i for i, x in enumerate(r) i... | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s164514947', 's431057466', 's619263633', 's814373978', 's332120362'] | [32168.0, 32388.0, 32300.0, 32380.0, 32384.0] | [142.0, 157.0, 182.0, 145.0, 139.0] | [343, 346, 376, 353, 348] |
p02684 | u169702930 | 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()))\nvisit = [-1 for i in range(n)]\nroot = []\nnow = 1\nlength = 0\nroot.append(now)\nif k > n:\n for i in range(n):\n if visit[now - 1] != 1:\n visit[now - 1] = 1\n now = a[now - 1]\n root.append(now)\n ... | ['Runtime Error', 'Accepted'] | ['s115143592', 's339515554'] | [32236.0, 32380.0] | [153.0, 153.0] | [659, 606] |
p02684 | u170839742 | 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()))\ngraph = [set() for i in range(N)]\nfor i, a in enumerate(A):\n graph[i].add(a - 1)\n\nstack = [0]\nseen = {0}\npath = []\ndist = [-1] * N\nwhile stack:\n cur = stack.pop()\n if dist[cur] != -1:\n break\n dist[cur] = len(path)\n ... | ['Runtime Error', 'Accepted'] | ['s402388748', 's378981158'] | [90848.0, 90788.0] | [527.0, 538.0] | [606, 608] |
p02684 | u173720816 | 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\nnode = [0] * (N + 1)\nindex = 1\nloop_flag = False\n\nfor i in range(1, N + 1):\n tmp = A[index - 1]\n if not node[tmp]:\n index = tmp\n node[index] += i\n else:\n pre = node[tmp]\n loop = index - node[tmp]\n... | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s183808140', 's326812736', 's488711038', 's533472351', 's800882678'] | [32380.0, 32300.0, 32380.0, 32388.0, 32188.0] | [144.0, 2207.0, 135.0, 148.0, 176.0] | [511, 437, 511, 520, 425] |
p02684 | u183383816 | 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,sys\nfrom sys import stdin, stdout\nfrom collections import Counter, defaultdict, deque\ninput = stdin.readline\nI = lambda:int(input())\nli = lambda:list(map(int,input().split()))\n\ndef case():\n n,k=li()\n a=li()\n d=defaultdict(int)\n i=0\n d[1]=1\n c=0\n ans=[1]\n while(a[i] n... | ['Wrong Answer', 'Accepted'] | ['s832143223', 's105283493'] | [37144.0, 37204.0] | [178.0, 163.0] | [682, 685] |
p02684 | u184817817 | 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\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nnxt = 1\nloop = []\ntset = set()\nfinal = -1\nwhile 1:\n loop.append(nxt)\n tset.add(nxt)\n nxt = a[nxt-1]\n if nxt in tset:\n final = nxt \n break\nm = -1\nfor i in range(len(loop)):\n if loop[i]==final:\n ... | ['Wrong Answer', 'Accepted'] | ['s897826603', 's945875315'] | [32112.0, 32380.0] | [180.0, 167.0] | [458, 442] |
p02684 | u185948224 | 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\nvisited = [-1] * N\nvisited[0] = 0\nnxt = 1\ncnt = 1\nfor i in range(N):\n nxt = A[nxt-1]\n if visited[nxt-1] == -1:\n visited[nxt-1] = cnt\n cnt += 1\n else:\n cycl = i + 1 - visited[nxt-1]\n m = visited[nxt... | ['Wrong Answer', 'Accepted'] | ['s657940895', 's375426197'] | [32380.0, 32376.0] | [216.0, 162.0] | [444, 438] |
p02684 | u187235390 | 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 collections import deque\nimport copy\ndef main():\n N, K = map(int, input().split())\n A = [(int(i) - 1) for i in input().split()]\n d = []\n for i in range(N):\n d.append(-1)\n d[0] = 0\n now = 0\n cycle = 0\n ans = -1\n a = 0\n flag = True\n while a < K:\n ... | ['Wrong Answer', 'Accepted'] | ['s563605143', 's942455033'] | [33720.0, 33736.0] | [144.0, 151.0] | [648, 659] |
p02684 | u191680842 | 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 = map(int,input().split())\nflag = [True]*n\np = 0\nrt = [1]\n\nwhile flag[p]:\n flag[p] = False\n p = A[p] -1\n rt.append(p+1)\n\nto_p = rt.index(rt[-1])\np2p = rt[to_p:-1]\np2p_len = len(p2p)\n\nif k < p2p_len:\n print(rt[k])\nelse:\n print(p2p[(k-to_p)%p2p_len])... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s319209846', 's599199517', 's651692228'] | [24568.0, 32308.0, 32200.0] | [46.0, 151.0, 147.0] | [299, 357, 356] |
p02684 | u192042624 | 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 sys\nimport math\nfrom collections import defaultdict\n\nN , K = map(int,input().split())\nA = list(map(int,input().split()))\n\nha = defaultdict(int)\nans = defaultdict(int)\ns = set()\ns.add(1)\nss = set()\nmod = 0\nmod2 = 0\nnext = 0\nind = 0\nflag = 0\nwhile True:\n if A[next] in s ... | ['Wrong Answer', 'Accepted'] | ['s017892521', 's258493366'] | [89860.0, 90008.0] | [455.0, 491.0] | [923, 870] |
p02684 | u197968862 | 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\ncitys = [False] * n\nnow = 0\ncitys[0] = True\ncostt = 0\nwhile True:\n now = a[now] - 1\n if citys[now]:\n costt += 1\n break\n else:\n citys[now] = True\n costt += 1\n\ncitys = [False] * n\ncitys[now] = True\... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s051920173', 's154333440', 's422020059'] | [32336.0, 32408.0, 32876.0] | [209.0, 225.0, 176.0] | [703, 707, 360] |
p02684 | u198668088 | 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 search_loop(list_route, now):\n list_route.append(list_a[now-1])\n for start in range(len(list_route)):\n for end in range(start+1, len(list_route)):\n if list_route[start] == list_route[end]:\n return start, end - start\n return search_loop(list_route, list_a[now-1])\n\n... | ['Wrong Answer', 'Accepted'] | ['s126576608', 's273892141'] | [32284.0, 32344.0] | [2206.0, 141.0] | [571, 479] |
p02684 | u204842730 | 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()))\nvisit=[1]\npos=0\nwhile True:\n visit.append(a[pos])\n if a[pos]-1 in visit:\n break\n pos=a[pos]-1\nloop=[]\nlooppos=visit[-1]-1\nwhile True:\n loop.append(a[looppos])\n looppos=a[looppos]-1\n if a[looppos] in loop:\n bre... | ['Runtime Error', 'Accepted'] | ['s765736268', 's506847337'] | [32296.0, 32380.0] | [2206.0, 142.0] | [413, 325] |
p02684 | u212328220 | 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())\nal = list(map(int, input().split()))\n\nvisited_towns = []\nfor i in range(N):\n next_town = al[visited_towns[i] - 1]\n if next_town in visited_towns:\n loop_sta = visited_towns.index((next_town)) \n loop_end = len(visited_towns) \n loop_length = loop_end ... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s673693873', 's952562369', 's902978882'] | [32384.0, 32216.0, 32376.0] | [68.0, 2206.0, 150.0] | [687, 497, 701] |
p02684 | u212786022 | 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\ncnt = [0]*N\ntown = 1\nfor i in range(K):\n if cnt[town-1] ==1:\n break\n\n cnt[town-1] += 1\n town = A[town-1]\n\n\nans1 = sum(cnt)\n\nimport copy\ntown2 = copy.deepcopy(town)\n\ncnt2 = [0]*N\n\nfor i in range(K):\n if cnt2[t... | ['Wrong Answer', 'Accepted'] | ['s060602640', 's504133985'] | [32388.0, 32008.0] | [214.0, 228.0] | [668, 713] |
p02684 | u213497190 | 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:A[i] for i in range(len(A))}\n\nif k <= n:\n current = 1\n for i in range(k):\n current = A[current]\n print(current)\nelse:\n current = 1\n pos = []\n visited = {i+1:0 for i in range(len(A))}\n for i in range(n... | ['Wrong Answer', 'Accepted'] | ['s888816162', 's793897600'] | [58492.0, 63392.0] | [281.0, 261.0] | [517, 881] |
p02684 | u216015528 | 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\ndef main():\n N, K = map(int, input().split())\n A = [int(x) - 1 for x in input().split()]\n\n way = []\n now = 0\n for _ in range(K):\n if now in way:\n loop_start = way.index(now)\n loop = way[loop_start:]\n K -= len(way[:loop_start])\n ... | ['Runtime Error', 'Accepted'] | ['s719719342', 's228062717'] | [32332.0, 32240.0] | [2206.0, 129.0] | [489, 541] |
p02684 | u217627525 | 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=0\n b=[1]\n res=[-1]*n\n res[0]=0\n flg=0\n now=1\n start=0\n t=1\n while flg==0:\n cnt+=1\n if res[a[now-1]-1]==-1:\n res[a[now-1]-1]=cnt\n b.append(a[now-1])\n ... | ['Wrong Answer', 'Accepted'] | ['s097215570', 's286269041'] | [32408.0, 32380.0] | [292.0, 161.0] | [710, 615] |
p02684 | u219494936 | 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 = list(map(lambda x: int(x)-1, input().split(" ")))\nassert len(towns) == N\n\nprint(towns)\n\nscore = {0: 0}\ncurrent = 0\nmove = 0\nwhile 1:\n next_town = towns[current]\n move += 1\n # print(f"move {current} to {next_town}")\n if score.get(next_town) is not None:\n ... | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s190230286', 's722468310', 's770208586', 's587551943'] | [40352.0, 9028.0, 32412.0, 32288.0] | [242.0, 24.0, 159.0, 186.0] | [842, 365, 1275, 1312] |
p02684 | u221301671 | 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\ni = 0\naa = 0\nvisited = {}\nfor i in range(k):\n aa = a[aa] - 1\n if aa in visited:\n s, e = visited[aa], i\n loop = e - s\n k = s + ((k - s) % loop)\n exit(0)\n visited[aa] = i\n\nprint(aa + 1)\n', 'n, k =... | ['Wrong Answer', 'Accepted'] | ['s641035618', 's127526708'] | [33144.0, 33104.0] | [137.0, 119.0] | [292, 337] |
p02684 | u224762261 | 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()))\nnow = 1\nused = [-228] * (n + 191)\nused[1] = -1\ncn = -292\nfor _ in range(k):\n now = A[now]\n if used[now] != -228:\n cn = _ + 1 - used[now]\n break\n used[now] = _\nif cn == -292:\n print(now)\n exit(0)\nfor ... | ['Wrong Answer', 'Accepted'] | ['s253730273', 's153315937'] | [32376.0, 32376.0] | [147.0, 132.0] | [351, 387] |
p02684 | u228759454 | 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 = {}\nd_n = {}\nfirst_d_n = {}\nfor i in range(N):\n d[i+1] = a[i]\n if i+1 == 1:\n d_n[i+1] = 1\n else:\n d_n[i+1] = 0\n\nm = 1\nk = 0 \nfirst_d_n[1] = 0\n\n\nwhile m:\n m = d[m]\n d_n[m] += 1\n k += 1\n if d_n[m] == 1:\n firs... | ['Wrong Answer', 'Accepted'] | ['s841913779', 's134485890'] | [76428.0, 76540.0] | [504.0, 451.0] | [554, 709] |
p02684 | u235783479 | 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\n\nvisit = {}\nn = 1\ncnt = 0\nremain = K\n# print("remain:", remain)\nwhile(n not in visit.keys()):\n visit[n] = cnt\n cnt+=1\n n = A[n]\n remain -= 1\n if (remain==0):\n print(n)\n exit()\n# remain -=1\n... | ['Wrong Answer', 'Accepted'] | ['s497477207', 's039291018'] | [32412.0, 32300.0] | [139.0, 149.0] | [542, 554] |
p02684 | u240630407 | 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 itertools\n# import math\nimport sys\n\n# import numpy as np\n\n# N = int(input())\n# S = input()\n# n, *a = map(int, open(0))\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n# B = list(map(int, input().split()))\n# tree = [[] for _ in range(N + 1)]\n# B_C = [list(map(int,input().spli... | ['Wrong Answer', 'Accepted'] | ['s181066640', 's455895070'] | [32368.0, 32360.0] | [179.0, 146.0] | [1357, 1359] |
p02684 | u242580186 | 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... | ['#include <bits/stdc++.h>\nusing namespace std;\n#define rep(i,n) for(int i=0; i<(n); i++)\n#define INF 1001001001\nusing ll = long long;\nusing dd = long double;\n\nconst int D = 60;\nconst int MAX_N = 20005;\nint to[D][MAX_N];\n\n\nint main() {\n int n;\n ll k;\n cin >> n >> k;\n rep(i,n) {\n cin ... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s372244879', 's443991391', 's718841097'] | [9008.0, 9052.0, 112180.0] | [24.0, 28.0, 1679.0] | [617, 636, 493] |
p02684 | u243714267 | 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\nli = [0]\nli.extend(list(map(int, input().split())))\ntuita = [0]*(n+1)\ncnt = 0\ntown = 1\n\ndef search(town, times):\n return times + 1\n if times == 0:\n return town\n return search(li[town], times - 1)\n\nwhile True:\n town = li[town]\n cnt += 1\n if tuita[town] == 0:\... | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s224850710', 's253106770', 's389034816', 's518892542', 's721409192', 's457878363'] | [32272.0, 32384.0, 32328.0, 32376.0, 32380.0, 32240.0] | [138.0, 136.0, 143.0, 136.0, 161.0, 187.0] | [523, 530, 557, 527, 555, 552] |
p02684 | u247830763 | 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())\nls = list(map(int,input().split()))\ni = 1\ndi = [-1]*10\ndi[0] = 0\nwhile True:\n if i == 1:\n a = ls[0]\n di[a-1] = i\n i += 1\n continue\n if i == k+1:\n print(a)\n break\n a = ls[a-1]\n if di[a-1] != -1:\n p = (k+1-di[a-1... | ['Runtime Error', 'Accepted'] | ['s630370089', 's566922866'] | [32376.0, 32260.0] | [68.0, 145.0] | [531, 371] |
p02684 | u249218427 | 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\nN,K = map(int, input().split())\nA = list(map(int, input().split()))\n\nM = K%N\n\ntown_now = 1\n\nfor _ in range(M):\n town_now = A[town_now-1]\n\nprint(town_now)', '# -*- coding: utf-8 -*-\n\nN,K = map(int, input().split())\nA = [0]+list(map(int, input().split()))\n\ntown_list = [-1,0]+[... | ['Wrong Answer', 'Accepted'] | ['s706744542', 's584209355'] | [32380.0, 32244.0] | [96.0, 169.0] | [179, 575] |
p02684 | u250061066 | 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\ndef main():\n N, K = [int(x) for x in stdin.readline().rstrip().split()]\n A = [int(x)-1 for x in stdin.readline().rstrip().split()]\n X = 0\n C = 0\n Log = []\n while C <= K:\n X = A[X-1]\n C += 1\n if (X in Log) == True:\n break\n Log +... | ['Runtime Error', 'Accepted'] | ['s160888985', 's578544393'] | [32320.0, 51036.0] | [2206.0, 344.0] | [487, 1016] |
p02684 | u250554058 | 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\nnum = list(map(int, input().split()))\nt = [-1] * n\ncount = 0\ns = 1\n\nwhile t[s - 1] == -1:\n if count == k:\n break\n\n t[s - 1] = count\n count += 1\n s = num[s - 1]\nelse:\n z = (k - t[s - 1]) % (count - t[s - 1])\n print(t.index(t[s - 1] + z + 1)\n', 'n, k = map(int... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s976399641', 's998146136', 's012466751'] | [9000.0, 32380.0, 32208.0] | [26.0, 161.0, 163.0] | [283, 290, 290] |
p02684 | u252729807 | 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#%%\nans = 0\ntotal = 0\n\nright = 0\nfor left in range(n):\n while total < k: \n if right == n: \n break\n else:\n total += A[right]\n right += 1 \n\n \n if total < k:\n ... | ['Wrong Answer', 'Accepted'] | ['s286804482', 's118701464'] | [32360.0, 59092.0] | [128.0, 277.0] | [661, 959] |
p02684 | u253389610 | 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\nfrom itertools import product\nn, m, x = [int(x) for x in input().split()]\na = np.stack([np.array(input().split(), dtype=int) for _ in range(n)])\ntot = np.sum(a, axis=0)\nif min(tot[1:]) < x:\n print(-1)\n exit(0)\ncost = tot[0]\nwhole = np.array(list(product([0,1],repeat=n)), dtype=bool)[... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s087781044', 's624095647', 's719090091', 's603690702'] | [27200.0, 32328.0, 32328.0, 32288.0] | [105.0, 2206.0, 2206.0, 122.0] | [446, 408, 382, 392] |
p02684 | u257265865 | 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()))\nnow=1\ncount=0\na=0\nl=[1]\nb=0\nc=0\nq=[True]*N\nwhile a==0and count<K:\n now=A[now-1]\n count+=1\n if q[now-1]:\n a=1\n else:\n l.append(now)\n q[now-1]=False\n \nb=l.index(now)\nc=count-b\nif count==K:\n prin... | ['Runtime Error', 'Accepted'] | ['s154759639', 's960763544'] | [32360.0, 32372.0] | [70.0, 160.0] | [346, 346] |
p02684 | u264312747 | 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())\nx = list(map(int, input().split()))\ncount = 1\nmachi = 0\nmachi_list = [0]\nnext_machi = x[machi] - 1\nmachi_dict = [0] * n\nmachi_dict[0] = 1\nwhile True:\n if machi_dict[next_machi] == 1:\n break\n count += 1\n print(machi_dict)\n machi_dict[next_machi] = 1\n ... | ['Wrong Answer', 'Accepted'] | ['s484024075', 's188564509'] | [142036.0, 32384.0] | [2544.0, 174.0] | [668, 646] |
p02684 | u266014018 | 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 = sys.stdin.buffer.readline\nN, K = map(int, input().split())\nA = list(map(lambda x: int(x)-1, input().split()))\nnow = 0\ndict_ = {}\nstack = []\nfor i in range(N):\n if now not in dict_:\n dict_[now] = A[now]\n stack.append(now)\n now = A[now]\n else:\n idx = sta... | ['Runtime Error', 'Accepted'] | ['s120274235', 's899131967'] | [36912.0, 36964.0] | [206.0, 160.0] | [421, 547] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.