hdu 5724-Chess

代码:

#include<bits/stdc++.h>
using namespace std;
const int N=;
int SG[<<N];
bool S[N];
void get_SG(int n)
{
memset(SG,,sizeof(SG));
for(int i=;i<n;i++)
{
memset(S,false,sizeof(S));
for(int j=;j>=;j--)
{
if(i&(<<j))
{
for(int k=j-;k>=;k--)
{
if(!(i&(<<k)))
{
int temp=i;
temp^=(<<j)^(<<k);
S[SG[temp]]=true;
break;
}
}
}
}
for(int j=;j<N;j++)
if(!S[j])
{
SG[i]=j;
break;
}
}
}
int main()
{
//ios::sync_with_stdio(false);
//cin.tie(0);
int t;
get_SG(<<);
scanf("%d",&t);
while(t--)
{
int n,m,a,ans=;
scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
int temp=;
while(m--)
{
scanf("%d",&a);
temp^=(<<(-a));
}
ans^=SG[temp];
}
if(ans)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return ;
}

hdu 5724-Chess(状态压缩+sg函数)的更多相关文章

  1. HDU 5724 Chess (状态压缩sg函数博弈) 2016杭电多校联合第一场

    题目:传送门. 题意:有n行,每行最多20个棋子,对于一个棋子来说,如果他右面没有棋子,可以移动到他右面:如果有棋子,就跳过这些棋子移动到后面的空格,不能移动的人输. 题解:状态压缩博弈,对于一行2^ ...

  2. HDU 5724 Chess(国际象棋)

    HDU 5724 Chess(国际象棋) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  3. hdu 5094 Maze 状态压缩dp+广搜

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4092176.html 题目链接:hdu 5094 Maze 状态压缩dp+广搜 使用广度优先 ...

  4. HDU 5724 Chess(SG函数+状态压缩)

    http://acm.split.hdu.edu.cn/showproblem.php?pid=5724 题意: 现在有一个n*20的棋盘,上面有一些棋子,双方每次可以选择一个棋子把它移动到其右边第一 ...

  5. HDU 5724 Chess (sg函数)

    Chess 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5724 Description Alice and Bob are playing a s ...

  6. HDU 5724 Chess(SG函数)

    Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submi ...

  7. HDU 5724 Chess(博弈论)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5724 [题目大意] 给出一个n行,每行有20格的棋盘,棋盘上有一些棋子,每次操作可以选择其中一个棋 ...

  8. POJ2425 A Chess Game[博弈论 SG函数]

    A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3917   Accepted: 1596 Desc ...

  9. poj 2425 A Chess Game(SG函数)

    A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3551   Accepted: 1440 Desc ...

随机推荐

  1. js实现轮播图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. SpringBoot与Docker1

    1:docker是一个开源的应用容器引擎: docker支持将软件编译成一个镜像:然后再镜像中各种软件做好配置,将镜像发布出去,其他使用者可以直接使用这个镜像: 运行中的这个镜像称为容器,容器启动是非 ...

  3. JS参差不齐的数组

    <html><head> <title>参差不齐的数组</title> <meta charset="utf-8"> & ...

  4. zw版【转发·台湾nvp系列Delphi例程】HALCON LocalMin2

    zw版[转发·台湾nvp系列Delphi例程]HALCON LocalMin2 procedure TForm1.Button1Click(Sender: TObject);var img : HUn ...

  5. Object-C-Foundation-数组排序

    系统类型排序; NSArray *goodsNames =@[@"computer",@"iphone",@"ipad"]; NSArray ...

  6. 3/5/2014 cfb 小心

    During each move the player can choose all lines of the matrix where dwarf is not on the cell with c ...

  7. Python: 正则表达式中的group()

    正则表达式中,group()用来提出分组截获的字符串,()用来分组 eg:

  8. Python-sys模块,异常

    习题1:题目:给一个不多于5位的正整数,要求:一.求它是几位数,二.逆序打印出各位数字. #encoding=utf-8 while True: try: num=int(raw_input(&quo ...

  9. 使用openssl生成SSL证书完全参考手册

    一般来说,配置HTTPS/SSL的步骤为: 1.生成足够强度的私钥.需要考虑:算法,广泛采用的一般是RSA.键长度,RSA默认为512,一般应选择2048.密码,虽然私钥不一定要加密存储,但是加密存储 ...

  10. 算法之路 level 01 problem set

    2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 ...