# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62637 | win11905 | Birokracija (COCI18_birokracija) | C++11 | 258 ms | 29724 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define long long long
const int N = 2e5+5;
int n;
long ans[N];
vector<int> g[N];
void dfs(int u) {
for(int v : g[u]) dfs(v), ans[u] += ans[v];
}
int main() {
fill_n(ans, N, 1);
scanf("%d", &n);
for(int i = 2, p; i <= n; ++i) {
scanf("%d", &p);
g[p].emplace_back(i);
}
dfs(1), dfs(1);
for_each(ans+1, ans+n+1, [](long x) { printf("%lld ", x); });
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |