Submission #44247

#TimeUsernameProblemLanguageResultExecution timeMemory
44247heonBirokracija (COCI18_birokracija)C++11
100 / 100
156 ms27288 KiB
#include<bits/stdc++.h> using namespace std; int n; long long sol[200005]; vector <int> graph[200005]; long long temp[200005]; int dfs(int a){ temp[a] = 1; for(auto x : graph[a]){ dfs(x); temp[a] += temp[x]; sol[a] += sol[x]; } sol[a] += temp[a]; } int main(){ cin >> n; for(int i = 2; i < n+1; i++){ int a; cin >> a; graph[a].push_back(i); } dfs(1); for(int i = 1; i <= n; i++){ cout << sol[i] << " "; } }

Compilation message (stderr)

birokracija.cpp: In function 'int dfs(int)':
birokracija.cpp:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#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...