Submission #580141

#TimeUsernameProblemLanguageResultExecution timeMemory
580141MuntherCarrotBirokracija (COCI18_birokracija)C++14
0 / 100
70 ms11728 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define all(x) x.begin(),x.end() int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<vector<int>> vv(n+1); vector<ll> vec(n+1,1),f(n+1,0); for(int i=1;i<n;i++){ int num; cin >> num; vv[num].push_back(i+1); } for(int i=n; i>0; i--){ if(vv[i].size() == 0){f[i]++;continue;} for(auto a : vv[i]){ f[i]++; vec[i]+=f[a]+vec[a]; } f[i]*=2; } for(int i=1;i<n+1;i++) cout << vec[i] << ' '; return 0; }
#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...