Submission #580232

#TimeUsernameProblemLanguageResultExecution timeMemory
5802327as__7Birokracija (COCI18_birokracija)C++17
50 / 100
1080 ms65536 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define int long long int32_t main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; //cin >> t; while(t--){ int n; cin >> n; map<int,int>mptot; map<int,deque<int> >mp; for(int i = 2;i<=n;i++){ int x; cin >> x; mp[x].push_front(i); } while(mp[1].size() > 0){ int x = 1; int tot = 0; while(mp[x].size() > 0){ tot++; x = mp[x].back(); } tot++; x = 1; int y = 0; while(mp[x].size() > 0){ mptot[x] += tot--; y = x; x = mp[x].back(); } mptot[x]++; mp[y].pop_back(); } mptot[1]++; for(int i = 1;i<=n;i++){ cout << mptot[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...