Submission #1006346

#TimeUsernameProblemLanguageResultExecution timeMemory
1006346DangerNoodle7591Birokracija (COCI18_birokracija)C++17
100 / 100
38 ms26964 KiB
#include <bits/stdc++.h> using namespace std; #define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); //#define endl '\n' #define int long long int //#define ll long long #define pb push_back #define p push #define f first #define s second #define N 200200 vector<int> adj[N]; int sz[N],deg[N]; int dfs(int x){ sz[x]=0; for(auto u:adj[x])sz[x]+=dfs(u); for(auto u:adj[x]){ deg[x]+=deg[u]+sz[u]; } sz[x]++; deg[x]++; return sz[x]; } signed main(){ lalala; int n;cin>>n; for(int i=2;i<=n;i++){ int a;cin>>a; adj[a].pb(i); } dfs(1); for(int i=1;i<=n;i++)cout<<deg[i]<<" "; cout<<endl; }
#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...