# 2017 Multi-University Training Contest - Team 6:1010&hdu6105、Gameia

Problem Description
Alice and Bob are playing a game called 'Gameia ? Gameia !'. The game goes like this :
0. There is a tree with all node unpainted initial.
1. Because Bob is the VIP player, so Bob has K chances to make a small change on the tree any time during the game if he wants, whether before or after Alice's action. These chances can be used together or separate, changes will happen in a flash. each change is defined as cut an edge on the tree.
2. Then the game starts, Alice and Bob take turns to paint an unpainted node, Alice go first, and then Bob.
3. In Alice's move, she can paint an unpainted node into white color.
4. In Bob's move, he can paint an unpainted node into black color, and what's more, all the other nodes which connects with the node directly will be painted or repainted into black color too, even if they are white color before.
5. When anybody can't make a move, the game stop, with all nodes painted of course. If they can find a node with white color, Alice win the game, otherwise Bob.
Given the tree initial, who will win the game if both players play optimally?

Input
The first line of the input gives the number of test cases T; T test cases follow.
Each case begins with one line with two integers N and K : the size of the tree and the max small changes that Bob can make.
The next line gives the information of the tree, nodes are marked from 1 to N, node 1 is the root, so the line contains N-1 numbers, the i-th of them give the farther node of the node i+1.

Limits
T100
1N500
0K500
1Pii

Output
For each test case output one line denotes the answer.
If Alice can win, output "Alice" , otherwise "Bob".

Sample Input
2 2 1 1 3 1 1 2

Sample Output
Bob Alice

CODE：

#include<bits/stdc++.h>
using namespace std;
int num[505],vis[505],pre[505];   //num：记录孩子节点数；vis：标记节点有没有被删除；pre：记录父节点
int main(){
int t,n,k,x,i,j,flag;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&k);
memset(num,0,sizeof(num));
pre[1]=1;
for(i=2;i<=n;i++){
scanf("%d",&x);
num[x]++;
pre[i]=x;
}
if(n%2) puts("Alice");
else{
memset(vis,0,sizeof(vis));
flag=0;
for(i=0;i<n;i++){
for(j=2;j<=n;j++){
if(!num[j]&&!vis[j]){
if(vis[pre[j]]){
flag=1;
break;
}
//满足条件就删除这两个节点
vis[j]=vis[pre[j]]=1;
num[pre[pre[j]]]--;
}
}
if(flag) break;
}
if(n/2-1>k) flag=1;
if(flag) puts("Alice");
else puts("Bob");
}
}
return 0;
}