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
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
这道题目可以说是模板题……
就是那个SG函数的求法貌似是结论,我不会证明。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
using namespace std;
const int N=,M=;
int cnt,fir[N],to[N],nxt[N];
void addedge(int a,int b){
nxt[++cnt]=fir[a];
to[fir[a]=cnt]=b;
}
int sqr(int x){return x*x;}
int tmp;
struct Circle{
int x,y,r;
Circle(int _=,int __=,int ___=){x=_;y=__;r=___;}
}c[N]; struct Point{
int x,id,tp;
Point(int _=,int __=,int ___=){x=_;id=__;tp=___;}
friend bool operator<(Point a,Point b){
double x=c[a.id].y+a.tp*sqrt(sqr(c[a.id].r)-sqr(tmp-c[a.id].x));
double y=c[b.id].y+b.tp*sqrt(sqr(c[b.id].r)-sqr(tmp-c[b.id].x));
if(x!=y)return x<y;return a.tp<b.tp;
}
}st[M]; bool cmp(Point a,Point b){return a.x<b.x;}
set<Point>s;set<Point>::iterator it; int fa[N],sg[N];
int DFS(int x){
sg[x]=;
for(int i=fir[x];i;i=nxt[i])
sg[x]^=DFS(to[i])+;
return sg[x];
} void Init(){
memset(fir,,sizeof(fir));
cnt=;
}
int T,n;
int main(){
scanf("%d",&T);
while(T--){
Init();scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d%d%d",&c[i].x,&c[i].y,&c[i].r);
st[*i-]=Point(c[i].x-c[i].r,i,-);
st[*i]=Point(c[i].x+c[i].r,i,);
}
sort(st+,st+*n+,cmp);
for(int i=;i<=*n;i++){
Point x=st[i];tmp=x.x;
if(x.tp==-){
it=s.upper_bound(Point(,x.id,));
if(it==s.end())addedge(fa[x.id]=,x.id);
else{
Point y=*it;
if(y.tp==)
addedge(fa[x.id]=y.id,x.id);
else
addedge(fa[x.id]=fa[y.id],x.id);
}
s.insert(Point(,x.id,));
s.insert(Point(,x.id,-));
}
else{
s.erase(Point(,x.id,));
s.erase(Point(,x.id,-));
}
}
printf(DFS()?"Alice\n":"Bob\n");
}
return ;
}