# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40396 | 2018-01-31T13:16:21 Z | szawinis | Birokracija (COCI18_birokracija) | C++14 | 182 ms | 30432 KB |
#include <bits/stdc++.h> using namespace std; const int N = 2e5+1; int n, sz[N]; vector<int> g[N]; long long dp[N]; void dfs(int u) { sz[u] = 1; for(int v: g[u]) { dfs(v); dp[u] += dp[v]; sz[u] += sz[v]; } dp[u] += sz[u]; } int main() { scanf("%d", &n); for(int i = 2, p; i <= n; i++) { cin >> p; g[p].push_back(i); } dfs(1); for(int i = 1; i <= n; i++) printf("%lld ", dp[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5076 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5076 KB | Output is correct |
2 | Correct | 6 ms | 5204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5312 KB | Output is correct |
2 | Correct | 6 ms | 5352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5352 KB | Output is correct |
2 | Correct | 5 ms | 5376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 6276 KB | Output is correct |
2 | Correct | 19 ms | 6564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 8184 KB | Output is correct |
2 | Correct | 65 ms | 9024 KB | Output is correct |
3 | Correct | 50 ms | 10304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 182 ms | 14156 KB | Output is correct |
2 | Correct | 119 ms | 17600 KB | Output is correct |
3 | Correct | 130 ms | 30432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 151 ms | 30432 KB | Output is correct |
2 | Correct | 134 ms | 30432 KB | Output is correct |
3 | Correct | 127 ms | 30432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 152 ms | 30432 KB | Output is correct |
2 | Correct | 124 ms | 30432 KB | Output is correct |
3 | Correct | 146 ms | 30432 KB | Output is correct |