HDU 5299 (tree-trimmed game) Circles games

Source: Internet
Author: User

Test instructions

Give you some circle center coordinates and radii to ensure that these circles are included or absent. Now two people do the game, take off a circle, and then the circle contains all to remove. Two people keep holding on until someone can't find a circle to remove he loses.

Ideas

The learning posture. This is a tree on the edge of the game model;
First, sort by the radius ascending, and then for each circle, find the first circle that contains it, and then even one edge. Achievement is completed.
The SG value of the leaf node is 0;
The SG value of the intermediate node is the XOR of the SG value of all its child nodes plus 1;
This can be built into a forest or a tree directly, without much difference. It would be convenient to build a tree.
You can see this blog;link of Eros.
And the Paper;link of the Jia Zhihao God Ox.

Reference code:
/ * #pragma warning (disable:4786) #pragma comment (linker, "/stack:0x800000") */#include <cassert>#include <cctype>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <sstream>#include <iomanip>#include <string>#include <vector>#include <list>#include <set>#include <map>#include <stack>#include <queue>#include <algorithm>#include <iterator>#include <utility>using namespace STD;Template<classT > t _abs (t N) {return(N <0? -N:N); }Template<classT > t _max (t A, T b) {return(! (A < b)? A:B); }Template<classT > t _min (t A, T b) {return(A < B. a:b); }Template<classT > t sq (t x) {returnx * x; }Template<classT > t gcd (t A, T b) {return(b! =0? Gcd<t> (b, a%b): a); }Template<classT > t LCM (t A, T b) {return(A/gcd<t> (A, b) * b); }Template<classT >BOOLInside (t A, T B, t C) {returnA<=b && b<=c; }#define MIN (A, B) ((a) < (b)? (a): (b))#define MAX (A, B) ((a) > (b)? (a): (b))#define F (i, n) for (int (i) =0; (i) < (n); + + (i))#define REP (i, S, T) for (int (i) = (s);(i) <= (t); + + (i))#define UREP (i, S, T) for (int (i) = (s);(i) >= (t);--(i))#define REPOK (i, S, T, O) for (int (i) = (s);(i) <= (t) && (o); + + (i))#define MEM0 (addr) memset ((addr), 0, sizeof ((addr)))#define MP (x, y) make_pair (x, y)#define REV (S, e) reverse (S, e )#define SET (P) memset (pair,-1, sizeof (p))#define CLR (P) memset (p, 0, sizeof (p))#define MEM (P, v) memset (P, V, sizeof (p))#define CPY (d, s) memcpy (d, S, sizeof (s))#define READ (f) freopen (F, "R", stdin)#define WRITE (f) freopen (F, "w", stdout)#define SZ (c) (int) c.size ()#define PB (x) push_back (x)#define FF First#define SS Second#define LL Long Long#define LD long double#define PII pair< int, int >#define PSI pair< string, int >#define LS u << 1#define RS u << 1 | 1#define Lson L, Mid, U << 1#define Rson Mid, R, u << 1 | 1Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-9;Const intMAXN =20010;Const intMoD =1000000007;structpoint{intX,y,r;} POINT[MAXN];intCMP (point A,point b) {returnA.R < B.R;}intDistintIintj) {return(LL) (point[i].x-point[j].x) * (point[i].x-point[j].x) + (POINT[I].Y-POINT[J].Y) * (POINT[I].Y-POINT[J].Y);}structedge{intTo,next;} EDGE[MAXN];intHead[maxn],tail;voidAddintFromintTo) {edge[tail].to = to;    Edge[tail].next = Head[from]; Head[from] = tail++;}intDfsintFrom) {intres =0; for(inti = head[from];i! =-1; i = edge[i].next) res ^= DFS (edge[i].to) +1;returnRes;}intMain () {//read ("In.txt");    intTscanf("%d", &t); while(t--) {intNscanf("%d", &n); Rep (I,0, N-1){scanf("%d%d%d", &AMP;POINT[I].X,&AMP;POINT[I].Y,&AMP;POINT[I].R);        } sort (point,point+n,cmp); Tail =0; MEM (head,-1); Rep (I,0, N-1){intFlag =0; Rep (j,i+1, N-1){intrr = (LL) POINT[J].R * POINT[J].R;intdis = dist (i,j);if(RR > Dis) {flag =1; Add (j,i); Break; }            }if(!flag) Add (n,i); }if(DFS (n)! =0)puts("Alice");Else            puts("Bob"); }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 5299 (tree-trimmed game) Circles games

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.