HDU 5299 L
来源:互联网 发布:淘宝企业店铺推广 编辑:程序博客网 时间:2024/04/26 20:31
Circles Game
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.
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。
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
210 0 16-100 0 90-50 0 1-20 0 1100 0 9047 0 123 0 1
Sample Output
AliceBob
Author
FZUACM
/* * 树上删边博弈 * 在平面x-O-y上有很多圆,这些圆的位置关系只有内含和相离,先操作如下: * 除去一个圆同时除去其包含的所有圆,最后不能操作的人输 * 抽象:直接包含圆是直接被包含圆的父节点,直接包含圆的所有直接被包含圆是兄弟 * 为处理方便不至于构造出来的是森林,可将整个平面看成一个最大的圆,所有的圆都被直接或间接包含在其中 */
#include <bits/stdc++.h>#define endl "\n"using namespace std;const int MAXN = 20000 + 7;int n;vector<int> linker[MAXN]; // 邻接表void Init() { for(int i = 0; i <= n; ++i) { linker[i].clear(); }}struct Circle { int x, y, r; friend bool operator<(Circle& a, Circle& b) { return a.r < b.r; }}cir[MAXN];int getDis(Circle a, Circle b) { return (a.x - b.x) * (a.x - b.x) + (a.y - b.y)*(a.y - b.y);}int dfs(int u) { int ret = 0; for(int i = 0; i < linker[u].size(); ++i) { ret ^= (dfs(linker[u][i]) + 1); } return ret;}int main() { int T; cin >> T; while(T--) { Init(); cin >> n; for(int i = 0; i < n; ++i) { cin >> cir[i].x >> cir[i].y >> cir[i].r; } sort(cir, cir + n); for(int i = 0; i < n; ++i) { bool hasSubCir = false; for(int j = i+1; j < n ; ++j) { // 内含关系,|r1 - r2| >= |o1 - o2| if((cir[j].r - cir[i].r) * (cir[j].r - cir[i].r) >= getDis(cir[i], cir[j])) { hasSubCir = true; linker[j].push_back(i); break; } } if(!hasSubCir) { linker[n].push_back(i); } } cout << (dfs(n) ? "Alice" : "Bob") << endl; } return 0;}
0 0
- HDU 5299 L
- HDU-OJ-2020 L 绝对值排序
- hdu 5024 最长的L型
- L - Oil Deposits HDU 1241 基础BFS
- 【暑期基础】L HDU 2011 多项式求和
- l
- .,l
- l
- l
- l
- ';l
- L
- l【
- ,l,
- L
- l
- L
- L
- NodeMCU读取dht11温湿度网页显示
- MySQL语法知识点
- 1012 u Calculate e
- JAVA基础易错选择题(笔试题文件流部分)
- 图的遍历-邻接矩阵-dfs
- HDU 5299 L
- mysql 的时间操作函数
- java一些基本知识(配置、debug调试、快捷键、junit test)
- 数据结构-栈:顺序栈与链栈的C++模板类实现
- 图的深度优先遍历
- 深入浅出SQL:4 聪明的表设计
- BZOJ4502: 串
- Java实现的字符串全排列算法
- mysql的安装,卸载,hive的安装。