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. POJ1017 【据说是贪心...】

    题意: 有6种面积的格子,给出这些格子的数量,然后有6*6的格子去容纳这6种面基,问最少需要几个6*6格子,使得所有类型的小格子被容纳. 思路: 按照面积的从大到小放. 一开始还是太天真,还要用各种1 ...

  2. c# dynamic 无法创建 泛型变量的问题

    IMyClass<T> FunctionA<T>( object arg_obj) { dynamic dyObj = arg_obj; return new MyClass& ...

  3. robotframework自动化系列:文本类型的下拉框

    对于下拉框定位和输入,这里主要遇到有两种类型的下拉选择. 其中一个类型是select-options格式,如图 这种方式的定位可以使用select from list by value或select ...

  4. SVG新手入门

    特点 矢量图 属性:形状的参数(都没有单位) 添加事件跟html一样 修改样式跟html一样 属性操作: setAttribute/getAttribute 图形 <svg width=&quo ...

  5. 使用c++的一些建议

    1: 不要使用宏,用const或enum定义常量 用inline避免函数的额外调用(使用inline的函数,块里面尽量不要使用循环和递归) 用template去荷花一些函数或者类型 用namespac ...

  6. Codeforces 1107G(dp)

    1.答案要取连续的区间疯狂暗示线段树. 2.外层枚举r,内层枚举l显然过于暴力. 3.考虑内层的优化.dp[i]:以第i位为结尾的答案(长度大于1的).dp[i] = max(第一种情况,第二种情况) ...

  7. 转--oracle查看允许的最大连接数和当前连接数等信息

    两个参数间的关系:sessions=1.1*processes+5 目前总结的语句,在查看数据的连接情况很有用,写完程序一边测试代码一边查看数据库连接的释放情况有助于分析优化出一个健壮的系统程序来. ...

  8. Java 修改编码格式的几种方式

    1.工作空间 workspase Window→Preferences→General→Workspace→Text file encoding→other→UTF-8 2.项目编码格式 右键项目名→ ...

  9. 模拟ssh的远程网络传输

    粘包产生的原因分析: 第一点:客户端向服务端发起命令请求,服务端接受命令请求,并返回对应的信息,如果信息过大,客户端一次接受不了,那么下一次请求依然返回 上一个命令的内容,就出现了粘包的情况. 第二点 ...

  10. const和volatile

    const是只读变量 const修饰的变量是只读的,其本质还是变量 const修饰的局部变量在栈上分配空间 const修饰的全局变量在全局数据区分配空间 const只在编译期有用,在运行期无用 con ...