Circles Game

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=5299

Description

There are n circles on a infinitely large table.With every two circle, either one contains another or isolates from the other.They are never crossed nor tangent.

Alice and Bob are playing a game concerning these circles.They take turn to play,Alice goes first:

1、Pick out a certain circle A,then delete A and every circle that is inside of A.

2、Failling to find a deletable circle within one round will lost the game.

Now,Alice and Bob are both smart guys,who will win the game,output the winner's name.

Input

The first line include a positive integer T<=20,indicating the total group number of the statistic.

As for the following T groups of statistic,the first line of every group must include a positive integer n to define the number of the circles.

And the following lines,each line consists of 3 integers x,y and r,stating the coordinate of the circle center and radius of the circle respectively.

n≤20000,|x|≤20000,|y|≤20000,r≤20000。

Output

If Alice won,output “Alice”,else output “Bob”

Sample Input

2

1

0 0 1

6

-100 0 90

-50 0 1

-20 0 1

100 0 90

47 0 1

23 0 1

Sample Output

Alice

Bob

Hint

题意

有一个平面,平面上有n个圆,圆与圆之间只有相离和包含的关系。

然后他们开始跑博弈论。

每个人可以拿圆和他所包含的圆。

如果谁不能拿了的话,那就输了。

问你谁能赢。

题解:

很显然,包含和相离关系,那么就是一个森林之间的关系。

然后把这个森林需要建立出来,这个就直接暴力就好了。

然后后面的博弈是一个很经典的东西。

叶子节点的SG值为0;中间节点的SG值为它的所有子节点的SG值加1 后的异或和。

然后直接跑就好了。

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+6;
vector<int> E[maxn];
struct node
{
int x,y,r;
};
node a[maxn];
int dp[maxn];
bool cmp(node A,node B)
{
return A.r>B.r;
}
int fa[maxn];
bool check(node A,node B)
{
long long k = 1ll*(A.x-B.x)*(A.x-B.x)+1ll*(A.y-B.y)*(A.y-B.y);
return k<=1ll*A.r*A.r;
}
void init()
{
memset(a,0,sizeof(a));
memset(fa,0,sizeof(fa));
memset(dp,0,sizeof(dp));
for(int i=0;i<maxn;i++)E[i].clear();
}
void dfs(int x,int fa)
{
dp[x]=0;
for(int j=0;j<E[x].size();j++)
{
int v = E[x][j];
if(v==fa)continue;
dfs(v,x);
dp[x]^=(dp[v]+1);
}
}
void solve()
{
init();
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r);
node k;
a[0].x=0,a[0].y=0,a[0].r=4e4+6;
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++)
{
for(int j=i-1;j>=0;j--)
if(check(a[j],a[i]))
{
fa[i]=j;
E[j].push_back(i);
break;
}
}
dfs(0,-1);
if(dp[0])cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)solve();
}

最新文章

  1. mysql awr 1.0.5 GA正式版发布
  2. VB模拟键盘输入的N种方法
  3. 理解Ruby中的作用域
  4. [moka同学笔记]yii2.0的下拉菜单与bootstrap下拉菜单
  5. hdu4547 lca tarjan
  6. BZOJ3906 : Trie
  7. 【PL/SQL练习】基本的PL/SQL语句
  8. UVa540 Team Queue
  9. PAT_1010 一元多项式求导
  10. 贪吃蛇 WPF
  11. python2精确除法
  12. java 判断两个时间段是否有交集
  13. 关于node.js的进程管理
  14. swift -2018 - 创建PCH文件
  15. 从头认识Spring-2.1 自己主动装配(2)-byType(2)
  16. 解决PJA错误
  17. python基础学习1-三元表达式和lambda表达式
  18. HTML&CSS精选笔记_CSS高级技巧
  19. python学习笔记(十)之格式化字符串
  20. lspci能看到ifconfig -a看不到网卡

热门文章

  1. 2015多校第7场 HDU 5379 Mahjong tree 构造,DFS
  2. .build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::set(int, double)&#39;
  3. 微信小程序实现图片上传,预览,删除
  4. artDialog的一些例子与一些属性的介绍。
  5. redis之(二十)redis的总结一
  6. webpy 调试
  7. CentOS6.5修改/etc/pam.d/sshd后root无法ssh登陆
  8. springboot+maven+thymeleaf配置实战demo
  9. apache 占用内存总量与每个apache进程的平均内存占用量计算
  10. python之并发编程(线程\进程\协程)