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 ...
随机推荐
- 如何优雅地使用 VSCode 来编辑 vue 文件?
最近有个项目使用了 Vue.js ,本来一直使用的是 PHPStorm 来进行开发,可是遇到了很多问题. 后来,果断放弃收费的 PHPStorm ,改用 vscode (Visual Stdio Co ...
- 在Eclipse中生成javadoc
在<thinking in java>一书的第一章提到javadoc,以前也看过,每次看到这部就跳过了,没有真正去尝试过什么样子,今天终于亲自实践了一下,原来真的挺简单:一.编写java源 ...
- sql语句将身份证号数字转换成特殊字符
SELECT Tname , STUFF(Idcard,,,'*********') as Idcard,Completion from demo
- [android] 天气app布局练习(四)
主要练习一下获取网络数据和解析xml MainActivity.java package com.example.weatherreport; import java.io.UnsupportedEn ...
- python的爬虫
requests库的安装 https://blog.csdn.net/xiaokuang5020/article/details/80580631 Response对象属性 属性 说明 r.statu ...
- Javascript获取页面表格中的数据
var main=mygrid.gettable("11"); //表示获取非固定列的表格 var main1=mygrid.gettable("01");// ...
- 基于Netty的NIO优化实践
1. 浅谈React模型 2. Netty TCP 3. Netty UTP
- git版本控制的使用
特别说明:本文所有知识笔记是学习“表严肃”同学的git课程记录所得. 前辈个人网站地址:http://biaoyansu.com 特此感谢前辈! 一.git是版本控制利器 二.本地创建仓库 1.进入新 ...
- mysql 的用法
SELECT CASEWHEN //当count(userId) = 0的时候 让其为null 不然报警告 // count(DISTINCT userId) 不用处理 count(userId ...
- CSS3,transform3D立体可拖拽正方体实现原理
---恢复内容开始--- 今天咱们来说一下,CSS中的3D效果 .如果你把transform真的掌握的和纯熟的话,就可以直接通过CSS做出很多很炫酷的效果,甚至.轮播图和选项卡都可以通过CSS来做,咱 ...