HDU 5724 Chess(SG函数)
Chess
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2605    Accepted Submission(s): 1092
The first line contains an integer T(T≤100)
, indicates the number of test cases.
For each test case, the first line contains a single integer n(n≤1000)
, the number of lines of chessboard.
Then n
lines, the first integer of ith line is m(m≤20)
, indicates the number of chesses on the ith line of the chessboard. Then m integers pj(1≤pj≤20)
followed, the position of each chess.
1
2 19 20
2
1 19
1 18
YES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
int sg[(<<)+];
int main(){ for(int i = ;i < (<<); i++){
int h[];
memset(h, -, sizeof(h));
int last = -;
for(int j = ; j < ; j++){ if(!((i >> j) & ))
last = j;
if(((i >> j) & )){
if(last != -){
h[sg[(i ^ ( << j)) ^ ( << last)]]=;
}
}
}
int j=;
while(h[j] != -) j++;
sg[i]=j;
}
int T;
scanf("%d", &T);
while(T--){
int n, tmp, m, ans=;
scanf("%d", &n);
for(int i = ; i <= n; i++){
scanf("%d", &m);
tmp = ;
for(int j = ; j <= m; j++){
int x;
scanf("%d", &x);
tmp ^= << ( - x);
}
ans ^= sg[tmp]; }
if(ans)
puts("YES");
else
puts("NO");
}
}
HDU 5724 Chess(SG函数)的更多相关文章
- HDU 5742  Chess  SG函数博弈
		
Chess Problem Description Alice and Bob are playing a special chess game on an n × 20 chessboard. ...
 - HDU 5724 Chess(国际象棋)
		
HDU 5724 Chess(国际象棋) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
 - S-Nim HDU 1536 博弈 sg函数
		
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...
 - HDU 5724 Chess(SG函数+状态压缩)
		
http://acm.split.hdu.edu.cn/showproblem.php?pid=5724 题意: 现在有一个n*20的棋盘,上面有一些棋子,双方每次可以选择一个棋子把它移动到其右边第一 ...
 - hdu 1848 简单SG函数
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1848 Problem Description 任何一个大学生对菲波那契数列(Fibonacci num ...
 - hdu 1809 求SG函数
		
A New Tetris Game(2) Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
 - HDU 5724 Chess (sg函数)
		
Chess 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5724 Description Alice and Bob are playing a s ...
 - HDU 5724 Chess (状态压缩sg函数博弈) 2016杭电多校联合第一场
		
题目:传送门. 题意:有n行,每行最多20个棋子,对于一个棋子来说,如果他右面没有棋子,可以移动到他右面:如果有棋子,就跳过这些棋子移动到后面的空格,不能移动的人输. 题解:状态压缩博弈,对于一行2^ ...
 - hdu 5724 Chess 博弈sg+状态压缩
		
Chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem De ...
 
随机推荐
- Android和kernel杂散点集合
			
Android: 1.编译 普通的编译: 1). source build/envsetup.sh 2).lunch 3).make -jx make kernel:只重新编译kernel部分镜像,但 ...
 - sleep函数作用(转)
			
表示当前线程暂时不参与cpu竞争,该函数会阻塞方法,一般在比较耗时的任务中执行了一段时间后会调用一下该方法避免当前任务一直霸占cpu,详情可以查看以下参考链接. 我们可能经常会用到 Thread.Sl ...
 - vue 报错./lib/html5-entities.js,  this relative module was not found
			
今天在做项目一直都挺正常的,我稍微休息一下回来就报这个错,我百度了半天也没找到答案.然后我只能重新安装vue-cli,奇迹发生了错误没有,然后我又休息了一会发现有报错了.气炸了都. 话不多多说直接上图 ...
 - PHP学习9——MySQL数据库
			
主要内容: MySQL的启动 MySQL数据库操作 数据库表设计 创建和查看表 修改表结构 MySQL语句操作 数据库备份与恢复 PHP操作MySQL数据库 面向对象的数据库操作 MySQL数据库是目 ...
 - C#实现Javascript的Splice方法
			
最近开始学习Javascript语言,看到splice方法,以下引用其说明:该方法是一个通用删除和插入元素的方法,它可以在数组指定的位置开始删除或插入元素.其包括3个参数:第一个参数指定插入的起始位置 ...
 - 2.VS2012为创建的类添加注释的模板
			
在项目中给类添加注释的优点: 1.方便查看这个类是为了那些功能 2.是成员小组中的谁负责编写的 根据自己的vs的安装路径找到类模板的位置:D:\Program Files (x86)\Microsof ...
 - Angular4 step by step.1
			
1.官网地址 :https://angular.cn/guide/quickstart 2.在线学习地址:https://embed.plnkr.co/?show=preview 3.效果截图哇哈哈
 - springboot自定义异常
			
SpringBoot自定义异常以及异常处理 在web项目中,我们可能需要给前端返回不同的提示码.例如:401表示没有权限,500代表位置异常,200代表请求成功等.但是这些提示码远远不能满足我们返回给 ...
 - WebClient用法小结(转载)
			
如果只想从特定的URI请求文件,则使用WebClient,它是最简单的.NET类,它只用一两条命令执行基本操作,.NET FRAMEWORK目前支持以http:.https:.ftp:.和 file: ...
 - ArcGIS DataStore手册——管理篇
			
第二章:ArcGIS DataStore管理维护 1.备份管理 备份的目的在于发生原始数据损坏或其他突发情况时,可避免数据丢失,并可快速的使用备份数据来恢复,以保证服务仍可使用. 单机模式下,可使用D ...