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?

InputThe 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 
T≤100T≤100 
1≤N≤5001≤N≤500 
0≤K≤5000≤K≤500 
1≤Pi≤i1≤Pi≤iOutputFor 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
这是一道博弈加上图论的题目,其中博弈的思想比较有意思。
先给出官方题解:

首先解释一下题意,题目说的是,树上不能有白点,否则Alice赢,即使这白点是被切开了,依旧是Alice赢。我只说关键的题意。
接着就是特权的作用:切断之后,防止黑色染到相邻节点,避免节点被染之后自己无处落脚。 题解看不懂的来这里,首先如果树的大小为3的话,alice必赢,因为可以染中间的点,然后无论bob是否能切断,alice都可以染白另一点。
如果是奇数大小的话,Alice必赢,因为Alice可以每次染父节点,将数的大小减二,长此以往,树的大小必然为3,这样Alice必赢。
如果bob能把树分成两个一组的点对,这样bob必赢,这句话里面隐藏了三条信息,首先数是偶数大小,第二bob拥有足够的特权数,即能大于等于n/2-1;
还有就是某一的节点的叶子节点数,如果是奇数个叶子节点的话,bob是无法通过足够的特权将数分成两个一对的点对。
你可以画一个杠铃,然后每个杠铃上再连接两个分开的点,这样就有两个三角型的形状连接在一起了,无论bob有多少特权,这图Alice必赢。虽然图的大小为偶数
且bob特权数足够,但是这有奇数个叶子节点,带上它的父节点,bob跟不上alice的节奏,他必输。这也就是递归所有子节点,求它的数目的原因。
这题大致就是这个思路了,没想明白的可以再仔细想想。既然做了ACM,那就放飞思想吧!

Gameia的更多相关文章

  1. 2017ACM暑期多校联合训练 - Team 6 1010 HDU 6105 Gameia (博弈)

    题目链接 Problem Description Alice and Bob are playing a game called 'Gameia ? Gameia !'. The game goes ...

  2. HDU 6105 - Gameia | 2017 Multi-University Training Contest 6

    /* HDU 6105 - Gameia [ 非平等博弈 ] | 2017 Multi-University Training Contest 6 题意: Bob 可以把一个点和周围所有点都染黑,还有 ...

  3. 2017多校第6场 HDU 6105 Gameia 博弈

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6105 题意:Alice和Bob玩一个游戏,喷漆!现在有一棵树上边的节点最开始都没有被染色.游戏规则是: ...

随机推荐

  1. IT兄弟连 Java Web教程 经典案例2

    案例需求:写一个用户登录的html页面有账号和密码,并在登录的Servlet中获取登录的账号和密码,如果账号是abc密码是123则向浏览器输出登录成功,否则向浏览器输出登录失败. 案例实现: ●  h ...

  2. Python:lambda表达式的两种应用场景

    01 lambda表达式 python书写简单,功能强大, 迅速发展成为 AI ,深度学习的主要语言.介绍Python中的lambda表达式,注意到,它只是一个表达式,不是语句啊. lambda的语法 ...

  3. 数位dp真·浅谈 By cellur925

    预警:由于是从$Vergil$学长那里和$Mathison$大神那里学来的,所以清一色记忆化搜索!qwq 巨佬的数位dp讲解(未来的咕咕日报头条): https://www.luogu.org/blo ...

  4. 「软件」仿站小工具v9.0

    仿站小工具是通过网址下载静态网页的工具.从输入的网址下载html代码,提取出JS.Css.Image.Picture.Flash等静态文件网址,再从下载完好的Css代码中提取出Image静态文件网址, ...

  5. spring cloud feign 调用接口报错"No message available

    There was an unexpected error (type=Internal Server Error, status=500). status 404 reading HelloServ ...

  6. the little schemer 笔记(4)

    第四章 numbers games 14 是原子吗 是的,数都是原子 (atom? n) 是真还是假,其中n是14 真,14 是原子 -3是数吗 是的,不过我们暂不考虑负数 3.14159是数吗 是的 ...

  7. 1051:A × B problem 大数相乘

    给你两个整数,请你计算A × B. 输入 数据的第一行是整数T(1 ≤ T ≤ 20),代表测试数据的组数.接着有T组数据,每组数据只有一行,包括两个非负整数A和B.但A和B非常大,Redraimen ...

  8. [洛谷P2417]课程

    题目链接: 点我 题目分析: 二分图最大匹配裸题,跑完匈牙利判断\(ans\)是否等于教室数即可 多组数据请注意初始化. 代码: #include<bits/stdc++.h> #defi ...

  9. [在读]Nodejs实战

    书到手的时候其实就已经过时,Express更新太快,因而书中的例子实践起来会有很多阻碍. 目前搁置状态.

  10. apache http server2.2 + tomcat5.5 性能调优

    httpd加tomcat做负载均衡,采用session复制方式共享session,采用http-proxy连接方式,打开status mod 一.没有做httpd和tomcat的启动参数修改,包括jv ...