/*
HDU 6105 - Gameia [ 非平等博弈 ] | 2017 Multi-University Training Contest 6
题意:
Bob 可以把一个点和周围所有点都染黑,还有 k 次割掉一条边的操作
Alice 可以把一个点染白
A先B后,问谁赢
分析:
如果图中不存在两两匹配,则Bob输
每一次两两匹配都需要一次割边,除了最后一次
如果没能力割边,Bob输
*/
#include <bits/stdc++.h>
using namespace std;
int t, n, k;
vector<int> G[505];
bool ans;
int dfs(int x)
{
int s = 1;
for (auto& y : G[x])
s += dfs(y);
if (s == 2) k--;
if (s > 2) ans = 0;
return s % 2;
}
int main()
{
scanf("%d", &t);
while (t--)
{
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i++) G[i].clear();
for (int i = 2; i <= n; i++)
{
int x; scanf("%d", &x);
G[x].push_back(i);
}
if (n&1) puts("Alice");
else
{
ans = 1;
dfs(1);
if (!ans || k < -1) puts("Alice");
else puts("Bob");
}
}
}

  

HDU 6105 - Gameia | 2017 Multi-University Training Contest 6的更多相关文章

  1. hdu 4930 Fighting the Landlords--2014 Multi-University Training Contest 6

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 Fighting the Landlords Time Limit: 2000/1000 MS ...

  2. HDU 6168 - Numbers | 2017 ZJUT Multi-University Training 9

    /* HDU 6168 - Numbers [ 思维 ] | 2017 ZJUT Multi-University Training 9 题意: .... 分析: 全放入multiset 从小到大,慢 ...

  3. HDU 5726 GCD (2016 Multi-University Training Contest 1)

      Time Limit: 5000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Description Give y ...

  4. HDU 5360 Hiking(优先队列)2015 Multi-University Training Contest 6

    Hiking Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total S ...

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

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

  6. hdu 6394 Tree (2018 Multi-University Training Contest 7 1009) (树分块+倍增)

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=6394 思路:用dfs序处理下树,在用分块,我们只需要维护当前这个点要跳出这个块需要的步数和他跳出这个块去 ...

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

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

  8. HDU 4951 Multiplication table(2014 Multi-University Training Contest 8)

    思路   如果进制为p    那么当x<p时 (p-1)*(p-x)=(p-(x+1))  *p +x     因为x<p  所以没有进位  所以高位上的数字为    p-(x+1). 根 ...

  9. HDU 4938 Seeing People(2014 Multi-University Training Contest 7)

    思路:根据出发时间把点往速度反方向移动 t*v的 的距离这样就可以当成 全部点一起出发,再把y轴上的点固定不动相当于x轴的点向(-v2,v1)方向移动 .可以把所有点映射到x轴上进行统计即可(要记住同 ...

随机推荐

  1. MySQL添加、修改、撤销用户数据库操作权限的一些记录

    查看MYSQL数据库中所有用户 SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user; ...

  2. linux 下tomcat出现 Native memory allocation (malloc) failed to allocate 1915224064 bytes for committing reserved memory问题

    ## There is insufficient memory for the Java Runtime Environment to continue.# Native memory allocat ...

  3. DB2部分查询SQL

    /* 部分SQL */ --添加主键 alter TABLE TABLE_SCHEMA.TABLE_NAME add constraint PK_TABLE_NAME primary key(COL1 ...

  4. 【51nod】2591 最终讨伐

    [51nod]2591 最终讨伐 敲51nod是啥评测机啊,好几次都编译超时然后同一份代码莫名奇妙在众多0ms中忽然超时 这道题很简单就是\(M\)名既被诅咒也有石头的人,要么就把石头给没有石头被诅咒 ...

  5. java日志框架系列(1):slf4j框架简介及依赖

    1.slf4j日志框架 1.简介 slf4j只是是日志规范,即只定义了接口,并没有实现这些接口. SLF4J的全称是Simple Logging Facade for Java,即简单日志门面.SLF ...

  6. Python基础总结之第六天开始【先简单认识一次函数】(新手可相互督促)

    午休后,看看电视,在回顾下新的知识----函数.相信很多小伙伴在学习python后 ,学到函数就会有一部分人放弃了,从努力到放弃(内容过于真实) 好希望我也能有很多粉丝,hhh.... 函数: 什么是 ...

  7. Unable to find optional library: org.apache.http.legacy 错误

    在目录adt-bundle-windows-x86_64-20140702\sdk\platforms\android-20或者 C:\Users\Administrator\AppData\Loca ...

  8. Lua的栈及基本栈操作

    Lua的栈及基本栈操作 https://blog.csdn.net/mydriverc2/article/details/51134737 https://blog.csdn.net/mydriver ...

  9. python numpy 删除array指定位置的元素

    如图:设计一个数组或者tuple,其中的元素是True或False,那么在False位置上的元素就会被删掉 索引的元素还可以是int型的数,这时候就代表,将原来的数组中指定位置的数放在当前的位置,且索 ...

  10. Image Processing and Computer Vision_Review:Local Invariant Feature Detectors: A Survey——2007.11

    翻译 局部不变特征探测器:一项调查 摘要 -在本次调查中,我们概述了不变兴趣点探测器,它们如何随着时间的推移而发展,它们如何工作,以及它们各自的优点和缺点.我们首先定义理想局部特征检测器的属性.接下来 ...