# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83140 | 2018-11-05T14:59:02 Z | Leonardo_Paes | Birokracija (COCI18_birokracija) | C++11 | 159 ms | 26040 KB |
#include <bits/stdc++.h> using namespace std; #define MAXN 200100 #define int long long 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]; } 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5136 KB | Output is correct |
2 | Correct | 6 ms | 5176 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5176 KB | Output is correct |
2 | Correct | 6 ms | 5192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5192 KB | Output is correct |
2 | Correct | 6 ms | 5252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 5872 KB | Output is correct |
2 | Correct | 20 ms | 6288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 49 ms | 7724 KB | Output is correct |
2 | Correct | 70 ms | 8148 KB | Output is correct |
3 | Correct | 50 ms | 9068 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 12572 KB | Output is correct |
2 | Correct | 132 ms | 14592 KB | Output is correct |
3 | Correct | 140 ms | 26040 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 156 ms | 26040 KB | Output is correct |
2 | Correct | 135 ms | 26040 KB | Output is correct |
3 | Correct | 135 ms | 26040 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 151 ms | 26040 KB | Output is correct |
2 | Correct | 135 ms | 26040 KB | Output is correct |
3 | Correct | 136 ms | 26040 KB | Output is correct |