# 洛谷P2148 [SDOI2009]E&D（博弈论）

#include<cstdio>
#include<bitset>
#include<iostream>
using namespace std;
const int N=10,M=N+1;//随便调大小
typedef bitset<M> B;
B s[M];
int ans[M][M];
inline int mex(B b){//干什么就不解释了吧
int i=0;
while(b[i])++i;
return i;
}
int main(){
int i,j,k;
for(i=2;i<=N;++i)
for(j=1,k=i-1;k;++j,--k)
s[i].set(ans[j][k]=mex(s[j]|s[k]));//枚举合并
for(i=0;i<N;++i)printf("%3d",i);puts("");
for(i=1;i<N;++i){//输出矩阵
printf("%2d:",i);
for(j=1;i+j<=N;++j)
printf("%3d",ans[i][j]);
puts("");
}
for(i=1;i<=N;++i){//输出对于每一个a，所有c+d=a的(c,d)的SG值集合
printf("%2d:SG%d ",i,mex(s[i]));
cout<<s[i]<<endl;
}
return 0;
}


 0:  1  2  3  4  5  6  7  8  9
1:  0  1  0  2  0  1  0  3  0
2:  1  1  2  2  1  1  3  3
3:  0  2  0  2  0  3  0
4:  2  2  2  2  3  3
5:  0  1  0  3  0
6:  1  1  3  3
7:  0  3  0
8:  3  3
9:  0


 1:SG0 00000000000
2:SG1 00000000001
3:SG0 00000000010
4:SG2 00000000011
5:SG0 00000000100
6:SG1 00000000101
7:SG0 00000000110
8:SG3 00000000111
9:SG0 00000001000
10:SG1 00000001001


#include<cstdio>
#define R register int
const int SZ=1<<21;
char ibuf[SZ],*pi=ibuf-1;
inline int in(){
while(*++pi<'-');
R x=*pi&15;
while(*++pi>'-')x*=10,x+=*pi&15;
return x;
}
int main(){
R T=in(),n,x,cnt,ans;
while(T--){
ans=0;
n=in()>>1;
while(n--){
cnt=0;
x=(in()-1)|(in()-1);
while(x&1)++cnt,x>>=1;
ans^=cnt;
}
puts(ans?"YES":"NO");
}
return 0;
}

posted @ 2018-04-13 17:50  Flash_Hu  阅读(486)  评论(0编辑  收藏  举报