将全部的圆化成树,然后就能够转化成树上的删边博弈问题....

Circles Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 881    Accepted Submission(s): 255

Problem 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
 
Author
FZUACM
 
Source
 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector> using namespace std; #pragma comment(linker, "/STACK:1024000000,1024000000") const int maxn=20200; int n;
struct Circle
{
int x,y,r;
bool operator<(const Circle& cir) const
{
return r>cir.r;
}
}circle[maxn]; double dist(int a,int b)
{
return sqrt((circle[a].x-circle[b].x)*(circle[a].x-circle[b].x)
+(circle[a].y-circle[b].y)*(circle[a].y-circle[b].y));
} vector<int> edge[maxn]; void Link(int u,int x)
{
bool fg=true;
for(int i=0,sz=edge[u].size();i<sz;i++)
{
int v=edge[u][i];
double dd=dist(x,v);
if(dd+circle[x].r>circle[v].r) continue;
fg=false;
Link(v,x);
return ;
}
if(fg) edge[u].push_back(x);
} int dp[maxn]; void dfs(int u)
{
int ret=-1;
for(int i=0,sz=edge[u].size();i<sz;i++)
{
int v=edge[u][i];
dfs(v);
if(ret==-1) ret=dp[v]+1;
else ret^=dp[v]+1;
}
if(ret==-1) ret=0;
dp[u]=ret;
} int main()
{
int T_T;
scanf("%d",&T_T);
while(T_T--)
{
scanf("%d",&n);
for(int i=1,x,y,r;i<=n;i++)
{
scanf("%d%d%d",&x,&y,&r);
//circle[i]=(Circle){x,y,r};
circle[i].x=x;
circle[i].y=y;
circle[i].r=r;
edge[i].clear();
}
edge[0].clear();
sort(circle+1,circle+1+n);
for(int i=1;i<=n;i++)
{
Link(0,i); dp[i]=0;
}
dfs(0);
if(dp[0]==0) puts("Bob");
else puts("Alice");
}
return 0;
}

HDOJ 5299 Circles Game 圆嵌套+树上SG的更多相关文章

  1. HDU 5299 Circles Game

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

  2. [SPOJ-CIRU]The area of the union of circles/[BZOJ2178]圆的面积并

    [SPOJ-CIRU]The area of the union of circles/[BZOJ2178]圆的面积并 题目大意: 求\(n(n\le1000)\)个圆的面积并. 思路: 对于一个\( ...

  3. 【题解】CIRU - The area of the union of circles [SP8073] \ 圆的面积并 [Bzoj2178]

    [题解]CIRU - The area of the union of circles [SP8073] \ 圆的面积并 [Bzoj2178] 传送门: \(\text{CIRU - The area ...

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

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

  5. HDU 5299 Circles Game 博弈论 暴力

    Circles Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5299 Description There are n circles on ...

  6. hdu 3094 A tree game 树上sg

    A tree game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Prob ...

  7. 【UVALive 4642】Malfatti Circles(圆,二分)

    题 给定三角形,求三个两两相切且与三角形的一条边相切的圆的半径. 二分一个半径,可以得出另外两个半径,需要推一推公式(太久了,我忘记了) #include<cstdio> #include ...

  8. 【百题留念】hdoj 1524 A Chess Game(dfs + SG函数应用)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1524 #include<stdio.h> #include<cstring> ...

  9. SPOJ CIRU - The area of the union of circles (圆的面积并)

    CIRU - The area of the union of circles no tags  You are given N circles and expected to calculate t ...

随机推荐

  1. Java-2-学习历程2:基础知识1,2,3文档、完整版视频资源、电子书籍下载

     Java学习历程:基础知识1,2,3文档.完整版视频资源.电子书籍 1.基础知识1,2.3可到下面地址下载: http://download.csdn.net/detail/iot_li/886 ...

  2. c13--数组

    // // main.c // 进制查表法 // // Created by xiaomage on 15/6/10. // Copyright (c) 2015年 xiaomage. All rig ...

  3. jQuery幻灯片插件Owl Carousel

    简介 Owl Carousel 是一个强大.实用但小巧的 jQuery 幻灯片插件,它具有一下特点: 兼容所有浏览器 支持响应式 支持 CSS3 过度 支持触摸事件 支持 JSON 及自定义 JSON ...

  4. SQL Server的三种分页方式

    直接上代码 --top not in方式 select top 条数 * from tablename where Id not in (select top 条数*页数 Id from tablen ...

  5. Selenium键盘鼠标操作总结

    鼠标操作 org.openqa.selenium.interactions.Actions 1.给元素设置焦点. 有时对于a标签等,为了不跳转到别的链接,但是需要设置焦点时就可使用. action.m ...

  6. Python 递归和二分查找

    # 二分查找l1 = [2,3,5,10,15,16,18,22,26,30,32,35,41,42,43,55,56,66,67,69,72,76,82,83,88] def two_search( ...

  7. SpringBoot(十一) Dubbo分布式与Zookeeper

    Dubbo简介 1.Dubbo简介 1. Dubbo是什么? dubbo就是个服务框架,如果没有分布式的需求,其实是不需要用的,只有在分布式的时候,才有dubbo这样的分布式服务框架的需求,并且本质上 ...

  8. 错误:java.lang.IllegalStateException: TimerTask is scheduled already

    Process: com.multak.cookaraclient, PID: 27384 java.lang.RuntimeException: Unable to resume activity ...

  9. Python学习——爬虫篇

    requests 使用requests进行爬取                 下面是我编写的第一个爬虫的脚本                   import requests # 导入reques ...

  10. java中常用的转义字符

    Day02_SHJavaTraing_4-3-2017 Java中允许使用转义字符‘\’来将其后的字符转变为特殊字符型常量. 一.JAVA中常用的转义字符