Submission #73329129


Source Code Expand

N = int(input())
A = [0] + list(map(int,input().split()))
ans = [-1 for _ in range(N+1)]

def get_goal(i):
  if A[i] == i:
    ans[i] = i
    return i
  
  ans[i] = get_goal(A[i])
  return ans[i]

for j in range(1, N+1):
  if ans[j] == -1:
    get_goal(j)
      
for a in ans[1:]:
  print(a)

Submission Info

Submission Time
Task C - Sugoroku Destination
User YH0
Language Python (CPython 3.13.7)
Score 0
Code Size 308 Byte
Status RE
Exec Time 505 ms
Memory 63308 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 17
RE × 1
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 10 ms 9172 KiB
00_sample_01.txt AC 10 ms 9136 KiB
00_sample_02.txt AC 10 ms 9316 KiB
01_random_03.txt AC 494 ms 63280 KiB
01_random_04.txt AC 499 ms 63236 KiB
01_random_05.txt AC 483 ms 63216 KiB
01_random_06.txt AC 480 ms 63308 KiB
01_random_07.txt AC 497 ms 63196 KiB
01_random_08.txt AC 501 ms 63228 KiB
01_random_09.txt AC 504 ms 63224 KiB
01_random_10.txt AC 472 ms 63164 KiB
01_random_11.txt AC 152 ms 28964 KiB
01_random_12.txt AC 128 ms 24872 KiB
01_random_13.txt AC 453 ms 54336 KiB
01_random_14.txt AC 30 ms 12128 KiB
01_random_15.txt AC 505 ms 59360 KiB
01_random_16.txt AC 11 ms 9208 KiB
01_random_17.txt RE 125 ms 62792 KiB