Submission #73334446


Source Code Expand

#include <bits/stdc++.h>

int main(){
    int n;
    std::cin >> n;
    std::vector <int> a(n + 1), ans(n + 1);
    for(int i = 1; i <= n; ++i) std::cin >> a[i];
    for(int i = n; i >= 1; --i) if(a[i] == i) ans[i] = i; else ans[i] = ans[a[i]];
    for(int i = 1; i <= n; ++i) std::cout << ans[i] << ' ';
    return 0;
}

Submission Info

Submission Time
Task C - Sugoroku Destination
User Eiralys
Language C++23 (GCC 15.2.0)
Score 300
Code Size 330 Byte
Status AC
Exec Time 106 ms
Memory 7852 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 18
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 1 ms 3440 KiB
00_sample_01.txt AC 1 ms 3420 KiB
00_sample_02.txt AC 1 ms 3628 KiB
01_random_03.txt AC 105 ms 7844 KiB
01_random_04.txt AC 105 ms 7840 KiB
01_random_05.txt AC 105 ms 7836 KiB
01_random_06.txt AC 105 ms 7844 KiB
01_random_07.txt AC 105 ms 7852 KiB
01_random_08.txt AC 106 ms 7844 KiB
01_random_09.txt AC 106 ms 7836 KiB
01_random_10.txt AC 105 ms 7840 KiB
01_random_11.txt AC 39 ms 4568 KiB
01_random_12.txt AC 32 ms 4684 KiB
01_random_13.txt AC 94 ms 7192 KiB
01_random_14.txt AC 7 ms 3696 KiB
01_random_15.txt AC 104 ms 7812 KiB
01_random_16.txt AC 1 ms 3496 KiB
01_random_17.txt AC 103 ms 7820 KiB