summaryrefslogblamecommitdiffstats
path: root/šola/p2/dn/DN07a_63230317.c
blob: 3bc5323964c702f22b4141770038458048dbf423 (plain) (tree)
























                                                  
#include <stdio.h>
#include <stdlib.h>
int globina (int * t) {
	fprintf(stderr, "-> %d %d\n", t[0], t[1]);
	if (!t[0] && !t[1])
		return 0;
	int r = 0;
	if (t[0])
		r = globina(t+2*t[0]);
	if (t[1]) {
		int g = globina(t+2*t[1]);
		if (g > r)
			r = g;
	}
	return r+1;
		
}
int main (void) {
	int n;
	scanf("%d\n", &n);
	int t[2*n];
	for (int i = 0; i < 2*n; i++)
		scanf("%d", &t[i]);
	printf("%d\n", globina(t));
}