Submission #1018560

#TimeUsernameProblemLanguageResultExecution timeMemory
1018560vjudge1Birokracija (COCI18_birokracija)C++17
70 / 100
60 ms16720 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=2e5+5; int const mod=1e9+7; vector<int> child[N]; int pay[N],sz[N]; void dfs(int node){ sz[node]=1; for(int i:child[node]){ dfs(i); pay[node]+=pay[i]; sz[node]+=sz[i]; } pay[node]+=sz[node]; } int main(){ int n; cin>>n; for(int i=2;i<=n;i++){ int p; cin>>p; child[p].push_back(i); } dfs(1); for(int i=1;i<=n;i++) cout<<pay[i]<<' '; cout<<endl; 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...