#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int Maxn=21;
int SG[1<<Maxn];
bool vis[Maxn];
void Get_SG(int num)
{
memset(vis,0,sizeof(vis));
for(int i=Maxn-1;i>=0;i--)
if(num&(1<<i))
{
int temp=num;
for(int j=i-1;j>=0;j--)
if(!(num&(1<<j)))
{
temp^=(1<<i)|(1<<j);
vis[SG[temp]]=1;
break;
}
}
for(int i=0;i<Maxn;i++)
if(!vis[i])
{
SG[num]=i;
return;
}
}
void init()
{
memset(SG,0,sizeof(SG));
for(int i=1;i<1<<Maxn;i++)
Get_SG(i);
}
int main()
{
int t,n,m,p,ans,s;
init();
scanf("%d",&t);
while(t--&&scanf("%d",&n)!=EOF)
{
for(ans=0;n--&&scanf("%d",&m);ans^=SG[s])
for(s=0;m--&&scanf("%d",&p);s|=1<<(20-p));
if(ans) printf("YES\n");
else printf("NO\n");
}
return 0;
}
HDU5724 2016 Multi-University Training Contest 1 (SG+预处理)
最新推荐文章于 2018-08-06 19:08:47 发布