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();
}

HDU 5299 Circles Game 博弈论 暴力的更多相关文章

  1. HDU 5299 Circles Game

    HDU 5299 思路: 圆扫描线+树上删边博弈 圆扫描线有以下四种情况,用set维护扫描线与圆的交点,重载小于号 代码: #pragma GCC optimize(2) #pragma GCC op ...

  2. 计数方法,博弈论(扫描线,树形SG):HDU 5299 Circles Game

    There are n circles on a infinitely large table.With every two circle, either one contains another o ...

  3. HDU 5299 圆扫描线 + 树上删边

    几何+博弈的简单组合技 给出n个圆,有包含关系,以这个关系做游戏,每次操作可以选择把一个圆及它内部的圆全部删除,不能操作者输. 圆的包含关系显然可以看做是树型结构,所以也就是树上删边的游戏. 而找圆的 ...

  4. HDU.2149 Public Sale (博弈论 巴什博弈)

    HDU.2149 Public Sale (博弈论 巴什博弈) 题意分析 巴什博奕裸题 博弈论快速入门 代码总览 #include <bits/stdc++.h> using namesp ...

  5. HDU.1846 Brave Game (博弈论 巴什博弈)

    HDU.1846 Brave Game (博弈论 巴什博弈) 题意分析 巴什博奕裸题 博弈论快速入门 代码总览 include <bits/stdc++.h> using namespac ...

  6. HDU 2920 分块底数优化 暴力

    其实和昨天写的那道水题是一样的,注意爆LL $1<=n,k<=1e9$,$\sum\limits_{i=1}^{n}(k \mod i) = nk - \sum\limits_{i=1}^ ...

  7. hdu 5277 YJC counts stars 暴力

    YJC counts stars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  8. HDU 5762 Teacher Bo (暴力)

    Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...

  9. hdu 4712 Hamming Distance(随机函数暴力)

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

随机推荐

  1. js中的return

    retrun true: 返回正确的处理结果. return false:分会错误的处理结果,终止处理. return:把控制权返回给页面(如果条件满足,后面的逻辑就不执行了). if(this.in ...

  2. Windows10下配置Linux下C语言开发环境

    今天为大家介绍如在Windows10下配置Linux下C语言开发环境,首先安装linux子系统:启用开发者模式 1.打开设置 2.点击更新和安全3.点击开发者选项 4.启用开发人员模式 5.更改系统功 ...

  3. Perl中文件读取操作

    Perl中文件读取操作 http://blog.csdn.net/yangxuan12580/article/details/51506216

  4. VPS性能测试(1):CPU物理个数、内核、超线程、多核心

    1.登录VPS界面,执行:cat /proc/cpuinfo,就会显示出VPS主机的CPU详细参数,如内核.频率.型号等等 2.主要参数physical_id表示物理CPU个数,cpu cores是内 ...

  5. sql server 学习笔记

    1. 修改student表中sdept字段改为varchar类型,长度为30,并且不为空 ) not null 2. 删除student表中的address列 alter table student ...

  6. PHP-5.3.27源码安装及nginx-fastcgi配置

    源码安装php cat /etc/redhat-release uname -rm wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.c ...

  7. Redis 基础使用(1)

    redis 数据库的使用场景介绍 redis 是 NoSQL 数据库中的一种,特别适合解决一些使用传统关系数据库难以解决的问题,redis 作为内存数据库,如果在不合适的场合,对内存的消耗是很大的,甚 ...

  8. jboss和tomcat有什么不同

    2.tomcat 是 JSP/Servlet 容器jboss 是 JEE 容器,JEE 包括JSP/Servlet,JMS, EJB,JAX-WS,JAX-RS,CDI等等, tomcat是完全开源, ...

  9. node采用的commonJs规范

    AMD与commonJS规范不同 同步加载 主要就是一个输出,一个引入,我也建了两个文件,一个输出文件一个引入文件 export.js ; ; ; function incCounter(){ cou ...

  10. beatfullsoup

    阅读目录 一 介绍 二 基本使用 三 遍历文档树 四 搜索文档树 五 修改文档树 六 总结 一 介绍 Beautiful Soup 是一个可以从HTML或XML文件中提取数据的Python库.它能够通 ...