There is n circles on a infinitely large table. With every-either one contains another or isolates from the other. They is 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 the is inside of a.
2, failling to find a deletable circle within one round would lost the game.
Now,alice and Bob are both smart guys,who would win the game,output the winner ' s name.
Inputthe 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 N Umber 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.
Outputif 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
This topic can be said to be a template problem ...
That's the way the SG function looks like a conclusion, I'm not going to prove it.
1#include <algorithm>2#include <iostream>3#include <cstring>4#include <cstdio>5#include <cmath>6#include <Set>7 using namespacestd;8 Const intn=20010, m=40010;9 intCnt,fir[n],to[n],nxt[n];Ten voidAddedge (intAintb) { Onenxt[++cnt]=Fir[a]; Ato[fir[a]=cnt]=b; - } - intSqrintx) {returnx*x;} the inttmp; - structcircle{ - intX,y,r; -Circle (int_=0,int__=0,int___=0) {x=_;y=__;r=___;} + }c[n]; - + structpoint{ A intX,ID,TP; atPoint (int_=0,int__=0,int___=0) {x=_;id=__;tp=___;} -FriendBOOL operator<(Point A,point b) { - DoubleX=c[a.id].y+a.tp*sqrt (Sqr (C[A.ID].R)-SQR (tmp-c[a.id].x)); - DoubleY=c[b.id].y+b.tp*sqrt (Sqr (C[B.ID].R)-SQR (tmp-c[b.id].x)); - if(x!=y)returnx<y;returna.tp<b.tp; - } in }st[m]; - to BOOLCMP (point A,point b) {returna.x<b.x;} + Set<Point>s;Set<Point>:: iterator it; - the intFa[n],sg[n]; * intDasointx) { $sg[x]=0;Panax Notoginseng for(intI=fir[x];i;i=Nxt[i]) -Sg[x]^=dfs (To[i]) +1; the returnSg[x]; + } A the voidInit () { +memset (Fir,0,sizeof(FIR)); -Cnt=0; $ } $ intT,n; - intMain () { -scanf"%d",&T); the while(t--){ -Init (); scanf ("%d",&n);Wuyi for(intI=1; i<=n;i++){ thescanf"%d%d%d",&c[i].x,&c[i].y,&C[I].R); -st[2*i-1]=point (c[i].x-c[i].r,i,-1); Wust[2*i]=point (C[i].x+c[i].r,i,1); - } AboutSort (st+1, st+2*n+1, CMP); $ for(intI=1; i<=2*n;i++){ -Point x=st[i];tmp=x.x; - if(x.tp==-1){ -It=s.upper_bound (Point (0, X.id,1)); A if(It==s.end ()) Addedge (fa[x.id]=0, x.id); + Else{ thePoint y=*it; - if(y.tp==1) $Addedge (fa[x.id]=y.id,x.id); the Else theAddedge (fa[x.id]=fa[y.id],x.id); the } theS.insert (Point (0, X.id,1)); -S.insert (Point (0, x.id,-1)); in } the Else{ theS.erase (Point (0, X.id,1)); AboutS.erase (Point (0, x.id,-1)); the } the } theprintf (DFS (0)?"alice\n":"bob\n"); + } - return 0; the}
Counting method, game theory (scan line, tree-shaped SG): HDU 5299 Circles Game