summaryrefslogtreecommitdiffstats
path: root/šola/p2/dn/DN07a_63230317.c
blob: 3bc5323964c702f22b4141770038458048dbf423 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#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));
}