Submission #73305159
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull=unsigned long long;
const int INF = 1e9;
const long long INFLL = (long long)1e18;
const double PI = acos(-1);
//cout << fixed << setprecision(15) << ans << '\n';
int main()
{
int n;cin>>n;
vector<int>a(n+1);
unordered_map<int,int>g;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]==i)g[i]=i;
}
for(int i=n;i>=1;i--)
{
if(g.count(i))continue;
else g[i]=g[a[i]];
}
for(int i=1;i<=n;i++)
{
cout<<g[i]<<" ";
}
cout<<"\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Sugoroku Destination |
| User | maou1 |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 611 Byte |
| Status | AC |
| Exec Time | 150 ms |
| Memory | 27280 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| 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 | 3568 KiB |
| 00_sample_01.txt | AC | 1 ms | 3600 KiB |
| 00_sample_02.txt | AC | 1 ms | 3568 KiB |
| 01_random_03.txt | AC | 150 ms | 27244 KiB |
| 01_random_04.txt | AC | 149 ms | 27244 KiB |
| 01_random_05.txt | AC | 148 ms | 27244 KiB |
| 01_random_06.txt | AC | 148 ms | 27240 KiB |
| 01_random_07.txt | AC | 149 ms | 27280 KiB |
| 01_random_08.txt | AC | 148 ms | 27256 KiB |
| 01_random_09.txt | AC | 148 ms | 27256 KiB |
| 01_random_10.txt | AC | 148 ms | 27256 KiB |
| 01_random_11.txt | AC | 52 ms | 13404 KiB |
| 01_random_12.txt | AC | 43 ms | 10152 KiB |
| 01_random_13.txt | AC | 132 ms | 24980 KiB |
| 01_random_14.txt | AC | 9 ms | 4792 KiB |
| 01_random_15.txt | AC | 146 ms | 26984 KiB |
| 01_random_16.txt | AC | 1 ms | 3372 KiB |
| 01_random_17.txt | AC | 127 ms | 27248 KiB |