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.
 

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
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
原创粉丝点击