Submission #44246

# Submission time Handle Problem Language Result Execution time Memory
44246 2018-03-30T20:47:03 Z heon Birokracija (COCI18_birokracija) C++11
70 / 100
170 ms 27492 KB
#include<bits/stdc++.h>

using namespace std;

int n;
int sol[200005];
vector <int> graph[200005];
int temp[200005];

int dfs(int a){
	temp[a] = 1;
	for(auto x : graph[a]){
		dfs(x);
		temp[a] += temp[x];
		sol[a] += sol[x];
	}
	sol[a] += temp[a];
}

int main(){
	cin >> n;
	for(int i = 2; i < n+1; i++){
		int a;
		cin >> a;
		graph[a].push_back(i);
	}
	dfs(1);
	for(int i = 1; i <= n; i++){
		cout << sol[i] << " ";
	}
}

Compilation message

birokracija.cpp: In function 'int dfs(int)':
birokracija.cpp:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 5360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5360 KB Output is correct
2 Correct 5 ms 5360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 5360 KB Output is correct
2 Correct 5 ms 5360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 5360 KB Output is correct
2 Correct 5 ms 5372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 6048 KB Output is correct
2 Correct 20 ms 6420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 7852 KB Output is correct
2 Correct 47 ms 8724 KB Output is correct
3 Correct 48 ms 10120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 170 ms 13380 KB Output is correct
2 Incorrect 135 ms 17008 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 155 ms 17008 KB Output is correct
2 Correct 151 ms 18416 KB Output is correct
3 Incorrect 129 ms 21740 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 21740 KB Output is correct
2 Correct 128 ms 22576 KB Output is correct
3 Incorrect 130 ms 27492 KB Output isn't correct