# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83139 | Leonardo_Paes | Birokracija (COCI18_birokracija) | C++11 | 200 ms | 14740 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 MAXN 200100
vector<int> grafo[MAXN];
pair<int,int> resp[MAXN];
pair<int,int> dfs (int u){
for(int i=0; i<grafo[u].size(); i++){
pair<int,int> x = dfs(grafo[u][i]);
resp[u].first+=x.first;
resp[u].second+=x.second+x.first;
}
return resp[u];
}
int main(){
int n;
cin >> n;
for(int i=2; i<=n; i++){
int p;
cin >> p;
grafo[p].push_back(i);
}
for(int i=1; i<=n; i++){
resp[i].first=resp[i].second=1;
}
pair<int,int> k = dfs(1);
for(int i=1; i<=n; i++){
cout << resp[i].second << " ";
}
cout << endl;
return 0;
}
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... |