Problem:
Score : 1100 points

Problem Statement

There is a tree with N vertices numbered 1, 2, ..., N.
The edges of the tree are denoted by (x_i, y_i).

On this tree, Alice and Bob play a game against each other.
Starting from Alice, they alternately perform the following operation:

Select an existing edge and remove it from the tree, disconnecting it into two separate connected components. Then, remove the component that does not contain Vertex 1.

A player loses the game when he/she is unable to perform the operation.
Determine the winner of the game assuming that both players play optimally.

Constraints

2 \leq N \leq 100000

1 \leq x_i, y_i \leq N

The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
x_2 y_2
:
x_{N-1} y_{N-1}

Output

Print Alice if Alice wins; print Bob if Bob wins.

Sample Input 1

5
1 2
2 3
2 4
4 5

Sample Output 1

Alice

If Alice first removes the edge connecting Vertices 1 and 2, the tree becomes a single vertex tree containing only Vertex 1.
Since there is no edge anymore, Bob cannot perform the operation and Alice wins.

Sample Input 2

5
1 2
2 3
1 4
4 5

Sample Output 2

Bob

Sample Input 3

6
1 2
2 4
5 1
6 3
3 2

Sample Output 3

Alice

Sample Input 4

7
1 2
3 7
4 6
2 3
2 4
1 5

Sample Output 4

Bob

Solution in Python (3.4.3) (judge verdict: Wrong Answer)

from collections import Counter
n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n-1):
	x, y = map(int, input().split())
	adj[x-1].append(y-1)
	adj[y-1].append(x-1)

nim = []

for i in adj[0]:
	dist = [10**10 for _ in range(n)]
	c = Counter()
	dist[0] = 0
	dist[i] = 1
	c[1] += 1
	s = [i]
	d_max = 1
	while s:
		l = s.pop()
		for v in adj[l]:
			if dist[v] == 10**10:
				dist[v] = dist[l]+1
				c[dist[v]] += 1
				d_max = max(d_max, dist[v])
				s.append(v)
	tmp = 0
	for j in range(d_max, 0, -1):
		tmp += 1
		if c[j]%2 == 0:
			tmp ^= 1
	nim.append(tmp)

res = 0
for z in nim:
	res ^= z

if res == 0:
	print("Bob")
else:
	print("Alice")