Code:
#include<cstdio> #include<cstring> using namespace std; #define maxn 1003 #define r 99 int n, x[maxn],y[maxn],SG[102][102],tag[6000000]; bool check(int xi,int yi){ if(xi==0||yi==0||xi==yi) return true; return false; } void get(int xi,int yi){ int id=yi*99+xi; for(int i=xi-1;i>=0;--i) if(!check(i,yi))tag[SG[i][yi]]=id; for(int i=yi-1;i>=0;--i) if(!check(xi,i))tag[SG[xi][i]]=id; for(int i=xi-1,j=yi-1;i>=0&&j>=0;--i,--j) if(!check(i,j))tag[SG[i][j]]=id; for(int i=0;;++i) if(tag[i]!=id) { SG[xi][yi]=i; break;} } int main(){ // freopen("input.in","r",stdin); for(int i=0;i<=r;++i) //y-cordinate for(int j=0;j<=r;++j) //x-cordinate if(!check(j,i)) get(j,i); int T; scanf("%d",&T); while(T--){ int n,ans=0,flag=0; scanf("%d",&n); for(int i=1;i<=n;++i){ scanf("%d%d",&x[i],&y[i]); if(check(x[i],y[i])) flag=1; ans^=SG[x[i]][y[i]]; } if(flag || ans) printf("^o^ "); else printf("T_T "); } return 0; }