题解:
打表找规律
总游戏的SG=子游戏的SG的Nim和
计算子游戏的SG(x)=mex(SG(next[x]))
用找规律加速计算
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=100009;
int TT;
int ans;
int n;
int SG(int x,int y){
if((x%2)&&(y%2))return 0;
return SG((x+1)/2,(y+1)/2)+1;
}
int main(){
scanf("%d",&TT);
while(TT--){
scanf("%d",&n);
ans=0;
while(n){
n-=2;
int x,y;
scanf("%d%d",&x,&y);
ans^=SG(x,y);
}
if(ans)printf("YES\n");
else printf("NO\n");
}
return 0;
}