# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83139 | 2018-11-05T14:57:14 Z | Leonardo_Paes | Birokracija (COCI18_birokracija) | C++11 | 200 ms | 14740 KB |
#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
# | 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 | 5116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5116 KB | Output is correct |
2 | Correct | 6 ms | 5116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5176 KB | Output is correct |
2 | Correct | 7 ms | 5176 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5176 KB | Output is correct |
2 | Correct | 6 ms | 5236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 5732 KB | Output is correct |
2 | Correct | 21 ms | 6048 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 7180 KB | Output is correct |
2 | Correct | 50 ms | 7420 KB | Output is correct |
3 | Correct | 51 ms | 8124 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 161 ms | 10568 KB | Output is correct |
2 | Incorrect | 132 ms | 12468 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 147 ms | 12468 KB | Output is correct |
2 | Correct | 136 ms | 12468 KB | Output is correct |
3 | Incorrect | 128 ms | 13208 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 13208 KB | Output is correct |
2 | Correct | 136 ms | 13208 KB | Output is correct |
3 | Incorrect | 200 ms | 14740 KB | Output isn't correct |