Test Instructions:Link
Method:SG function, SG table?
parsing:The test instructions of this problem is very good for you to build. n pieces do not affect each other, representing the n situation does not affect each other. Then, each situation of the pieces can go to the point of the situation is the sub-game, all the sub-game to the MEX operation will be able to get the SG value of each situation. However, it is wrong to find out that the SG table is out of the way because we have not considered some of the required failures. After drawing analysis and other discoveries, if the initiator first go, go to the point (x, y) If you go to the x==y| | x==0| | Y==0 situation, then the initiator directly GG. It is obvious that the initiator is not going to go this way, and all people will not go through these points unless they are forced to do so. So we might as well give their SG value 0. These points will not be present in this game unless the original pieces are at these points. It's OK to consider these conditions.
Code:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 1010#define Musing namespace STD;intT,n;intSSGG[M][M];structnode{intx, y;} Pt[n];intsgintXintY) {if(x==0|| y==0)return 0;if(x==y)returnssgg[x][y]=0;if(ssgg[x][y]!=-1)returnSsgg[x][y];BOOLv[10010];memset(V,0,sizeof(v)); for(intk=1;; k++) {if(x-k<=0&&y-k<=0) Break;if(x-k>0&&x-k!=y) V[SG (x-k,y)]=1;if(y-k>0&&y-k!=x) V[SG (x,y-k)]=1;if(x-k>0&&y-k>0) V[SG (x-k,y-k)]=1; } for(intI=0;; i++)if(!v[i])returnSsgg[x][y]=ssgg[y][x]=i;}intMain () {scanf("%d", &t);memset(ssgg,-1,sizeof(SSGG)); while(t--) {scanf("%d", &n);intflag=0; for(intI=1; i<=n;i++) {scanf("%d%d", &PT[I].X,&PT[I].Y);if(pt[i].x==0|| pt[i].y==0|| PT[I].X==PT[I].Y) flag=1; }if(flag) {puts("^o^");Continue; }intans=0; for(intI=1; i<=n;i++) {ANS^=SG (PT[I].X,PT[I].Y); }if(ans==0)puts("t_t");Else puts("^o^"); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Bzoj 1457 board game SG function