HDU 5299 Circles Game 博弈论 暴力
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 博弈论 暴力的更多相关文章
- HDU 5299 Circles Game
HDU 5299 思路: 圆扫描线+树上删边博弈 圆扫描线有以下四种情况,用set维护扫描线与圆的交点,重载小于号 代码: #pragma GCC optimize(2) #pragma GCC op ...
- 计数方法,博弈论(扫描线,树形SG):HDU 5299 Circles Game
There are n circles on a infinitely large table.With every two circle, either one contains another o ...
- HDU 5299 圆扫描线 + 树上删边
几何+博弈的简单组合技 给出n个圆,有包含关系,以这个关系做游戏,每次操作可以选择把一个圆及它内部的圆全部删除,不能操作者输. 圆的包含关系显然可以看做是树型结构,所以也就是树上删边的游戏. 而找圆的 ...
- HDU.2149 Public Sale (博弈论 巴什博弈)
HDU.2149 Public Sale (博弈论 巴什博弈) 题意分析 巴什博奕裸题 博弈论快速入门 代码总览 #include <bits/stdc++.h> using namesp ...
- HDU.1846 Brave Game (博弈论 巴什博弈)
HDU.1846 Brave Game (博弈论 巴什博弈) 题意分析 巴什博奕裸题 博弈论快速入门 代码总览 include <bits/stdc++.h> using namespac ...
- HDU 2920 分块底数优化 暴力
其实和昨天写的那道水题是一样的,注意爆LL $1<=n,k<=1e9$,$\sum\limits_{i=1}^{n}(k \mod i) = nk - \sum\limits_{i=1}^ ...
- hdu 5277 YJC counts stars 暴力
YJC counts stars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- HDU 5762 Teacher Bo (暴力)
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
- hdu 4712 Hamming Distance(随机函数暴力)
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
随机推荐
- C++学习之路(五):复制构造函数与赋值运算符重载
之前没有细想过两者的区别,今天对此进行简要记录,后续完善补充. 复制构造函数是在类对象被创建时调用的,但是赋值运算符是被已经存在的对象调用完成赋值操作. 复制构造函数只在对象实例化时才被调用,即在复制 ...
- 网络设备之pci_driver
每个pci驱动都有一个pci_driver实例,用以描述驱动名称,支持的设备信息,以及对应的操作函数: /* 描述一个pci设备,每个pci驱动必须创建一个pci_driver实例 */ struct ...
- linux dpm机制分析(下)【转】
转自:http://blog.csdn.net/lixiaojie1012/article/details/23707901 1 设备注册到dpm_list路径 (Platform_devi ...
- mapper.xml中的<sql>标签
原文链接:http://blog.csdn.net/a281246240/article/details/53445547 sql片段标签<sql>:通过该标签可定义能复用的sql语句片段 ...
- ASPxgridview 编辑列初始化事件
在初始化编辑咧的时候,给其赋值或者是disable等等.... 贴上代码 protected void master_CellEditorInitialize(object sender, ASPxG ...
- thinkphp模板常用的方法
thinkphp模板我是看了3.2的文档,对里面的东西过了一遍,然后在写到需要用到模板的东西的时候就有印象,有的能直接回顾,但是有的就可能只知道有这个东西,但是不知道怎么用,所以就重新查手册,这个的话 ...
- 第一次用python编写的小程序
print ("*******数字游戏*********")temp = input ("猜猜小红现在心里想的是什么数字呢?")guess = int(temp ...
- mac系统安装mysql
1.下载 打开官网:https://www.mysql.com 进入DOWNLOADS--->Community--->MySQL Community Server--->DOWNL ...
- C# 实现动态添加列,新增合计行,求和
DataTable da = CommonBLL.GetList("*", "sys_dict", "IfState=1 and DictTypeId ...
- layui文件单文件和多文件的上传、预览以及删除和修改
活不多说,直接上代码 单文件上传 1.HTML <blockquote class="layui-elem-quote layui-quote-nm" style=" ...