HDU 5299 (树删边博弈)
来源:互联网 发布:数据库下载 编辑:程序博客网 时间:2024/05/22 21:47
Circles Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1446 Accepted Submission(s): 456
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
所有的圆之间构成一棵数的关系,然后就是树上的删边博弈.
建树可以扫描线,然后暴力出奇迹~
#include <bits/stdc++.h>using namespace std;#define maxn 41111#define eps 1e-8struct circle { double x, y, r; bool operator < (const circle &a) const { return r < a.r; }}p[maxn];int n;int cnt = 0;struct node { int u, v, next;}edge[maxn*4];int tot, head[maxn], fa[maxn];bool in (int i, int j) {//判断圆i是不是在j中 double xx = p[i].x-p[j].x; double yy = p[i].y-p[j].y; return xx*xx+yy*yy <= p[j].r*p[j].r;}void add_edge (int u, int v) { edge[tot].u = u, edge[tot].v = v, edge[tot].next = head[u], head[u] = tot++;}int dfs (int u) { int ans = 0; for (int i = head[u]; i != -1; i = edge[i].next) { int v = edge[i].v; ans ^= (dfs (v)+1); } return ans;}int main () { //freopen ("in.txt", "r", stdin); int t; scanf ("%d", &t); while (t--) { scanf ("%d", &n); memset (head, -1, sizeof head); for (int i = 0; i < n; i++) fa[i] = i; tot = cnt = 0; for (int i = 0; i < n; i++) { scanf ("%lf%lf%lf", &p[i].x, &p[i].y, &p[i].r); } sort (p, p+n); for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { if (in (i, j)) { fa[i] = j; add_edge (j, i); break; } } } int ans = 0; for (int i = 0; i < n; i++) if (fa[i] == i) { ans ^= (dfs (i)+1); } printf ("%s\n", ans ? "Alice" : "Bob"); } return 0;}
0 0
- HDU 5299 (树删边博弈)
- hdu 5299 树上博弈
- HDU博弈
- HDU 5299 Circles Game(树&博弈)
- hdu 5299 Circles Game(博弈)
- HDU 5754 博弈(威佐夫博弈)
- John-博弈hdu
- hdu 1850 第一次博弈
- HDU 4023 贪心+博弈
- 【dfs博弈】HDU 4155
- hdu 2516 博弈
- HDU 1079 博弈
- 威佐夫博弈 hdu 2177
- HDU 1536 (博弈SG)
- hdu 2149 (博弈)
- HDU 2147 bash博弈
- hdu 1079(博弈)
- hdu 1517 (博弈)
- c++ 重载和覆盖隐藏
- Java实现排序算法1:5种易理解的算法
- 使用可重入函数进行更安全的信号处理
- spring同时集成redis和mongodb时遇到多个资源文件加载的问题
- 码农小汪-剑指Offer之22-二叉树中和为某一值的路径
- HDU 5299 (树删边博弈)
- Webbench-1.5开源软件工具源码深度剖析
- js事件总结<未完----待续>
- IDEA快捷键 for Mac
- 使用递归的四条基本法则
- Spring框架AOP
- 安卓的一点小问题
- SpringMVC -- @PathVariable/Rest风格的URL HiddenHttpMethodFilter (2)
- mybatis-redis项目分析