提出 #73308411


ソースコード 拡げる

N = int(input())
A = list(map(int, input().split()))

root = [0] * N
for i in range(N - 1, -1, -1):
    if A[i] == i+1:
        root[i] = i+1
    else:
        root[i] = root[A[i]-1]
        
print(*root)

提出情報

提出日時
問題 C - Sugoroku Destination
ユーザ Nikitty
言語 Python (PyPy 3.11-v7.3.20)
得点 300
コード長 214 Byte
結果 AC
実行時間 370 ms
メモリ 198204 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 18
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 48 ms 79464 KiB
00_sample_01.txt AC 47 ms 79316 KiB
00_sample_02.txt AC 47 ms 79556 KiB
01_random_03.txt AC 369 ms 193976 KiB
01_random_04.txt AC 366 ms 196124 KiB
01_random_05.txt AC 369 ms 195384 KiB
01_random_06.txt AC 367 ms 195848 KiB
01_random_07.txt AC 370 ms 196420 KiB
01_random_08.txt AC 368 ms 197248 KiB
01_random_09.txt AC 366 ms 198180 KiB
01_random_10.txt AC 370 ms 197400 KiB
01_random_11.txt AC 175 ms 141092 KiB
01_random_12.txt AC 159 ms 136916 KiB
01_random_13.txt AC 331 ms 178688 KiB
01_random_14.txt AC 81 ms 111628 KiB
01_random_15.txt AC 362 ms 198204 KiB
01_random_16.txt AC 50 ms 79200 KiB
01_random_17.txt AC 362 ms 192248 KiB