Submission #580385

#TimeUsernameProblemLanguageResultExecution timeMemory
580385MrM7mdBirokracija (COCI18_birokracija)C++17
100 / 100
49 ms7076 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" const int MOD = 1e9 + 7; int a[1000000]; int add[1000000]; int b[1000050]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; b[0]=1000000; for(int i=1;i<n;i++){ cin >> b[i]; b[i]--; } for(int t=n-1;t>=0;t--){ add[b[t]]+=add[t]+1; a[t]++; a[b[t]]+=a[t]+add[t]; } for(int i=0;i<n;i++){ cout<<a[i]+add[i]<<' '; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...