# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44247 | 2018-03-30T20:48:13 Z | heon | Birokracija (COCI18_birokracija) | C++11 | 156 ms | 27288 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5224 KB | Output is correct |
2 | Correct | 6 ms | 5224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5224 KB | Output is correct |
2 | Correct | 5 ms | 5224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5224 KB | Output is correct |
2 | Correct | 5 ms | 5392 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 5812 KB | Output is correct |
2 | Correct | 27 ms | 6328 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 7744 KB | Output is correct |
2 | Correct | 48 ms | 8020 KB | Output is correct |
3 | Correct | 48 ms | 8932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 156 ms | 12192 KB | Output is correct |
2 | Correct | 130 ms | 14344 KB | Output is correct |
3 | Correct | 129 ms | 27288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 149 ms | 27288 KB | Output is correct |
2 | Correct | 148 ms | 27288 KB | Output is correct |
3 | Correct | 130 ms | 27288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 155 ms | 27288 KB | Output is correct |
2 | Correct | 132 ms | 27288 KB | Output is correct |
3 | Correct | 128 ms | 27288 KB | Output is correct |