题意

Language:Default
Cutting Game
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 6007 Accepted: 2190

Description

Urej loves to play various types of dull games. He usually asks other people to play with him. He says that playing those games can show his extraordinary wit. Recently Urej takes a great interest in a new game, and Erif Nezorf becomes the victim. To get away from suffering playing such a dull game, Erif Nezorf requests your help. The game uses a rectangular paper that consists of W*H grids. Two players cut the paper into two pieces of rectangular sections in turn. In each turn the player can cut either horizontally or vertically, keeping every grids unbroken. After N turns the paper will be broken into N+1 pieces, and in the later turn the players can choose any piece to cut. If one player cuts out a piece of paper with a single grid, he wins the game. If these two people are both quite clear, you should write a problem to tell whether the one who cut first can win or not.

Input

The input contains multiple test cases. Each test case contains only two integers W and H (2 <= W, H <= 200) in one line, which are the width and height of the original paper.

Output

For each test case, only one line should be printed. If the one who cut first can win the game, print "WIN", otherwise, print "LOSE".

Sample Input

2 2
3 2
4 2

Sample Output

LOSE
LOSE
WIN

Source

POJ Monthly,CHEN Shixi(xreborner)

分析

对于任何一个人,都不会先剪出1*n或者n*1,应该这样就必败了。

那我们考虑一个状态的后继中,最小的边也是2,这样就可以避免之前的问题,也不需要考虑类似ANTI-SG。

一旦出现2*2,2*3,3*2,这些都成了终止状态,不论怎么剪都会出现1*n,或者n*1

mex求出不属于集合的最小整数

纸片的SG值是后者的纸片的SG的异或值。

还是考察SG函数

时间复杂度\(O(n^3)\)

代码

#include<iostream>
#include<cstring>
const int N=206;
int n,m,sg[N][N];
int SG(int x,int y){
bool f[N];
memset(f,0,sizeof f);
if(sg[x][y]!=-1) return sg[x][y];
for(int i=2;i<=x-i;++i) f[SG(i,y)^SG(x-i,y)]=1;
for(int i=2;i<=y-i;++i) f[SG(x,i)^SG(x,y-i)]=1;
int t=0;
while(f[t]) ++t;
return sg[x][y]=t;
}
int main(){
// freopen(".in","r",stdin),freopen(".out","w",stdout);
memset(sg,-1,sizeof sg);
sg[2][2]=sg[2][3]=sg[3][2]=0;
while(~scanf("%d%d",&n,&m)) puts(SG(n,m)?"WIN":"LOSE");
return 0;
}

POJ2311 Cutting Game的更多相关文章

  1. [poj2311]Cutting Game_博弈论

    Cutting Game poj-2311 题目大意:题目链接 注释:略. 想法: 我们发现一次操作就是将这个ICG对应游戏图上的一枚棋子变成两枚. 又因为SG定理的存在,记忆化搜索即可. 最后,附上 ...

  2. POJ2311 Cutting Game 博弈 SG函数

    Cutting Game Description Urej loves to play various types of dull games. He usually asks other peopl ...

  3. POJ2311 Cutting Game(博弈论)

    总时间限制: 1000ms 内存限制: 65536kB 描述 Urej loves to play various types of dull games. He usually asks other ...

  4. 【博弈论】【SG函数】poj2311 Cutting Game

    由于异或运算满足结合律,我们把当前状态的SG函数定义为 它所能切割成的所有纸片对的两两异或和之外的最小非负整数. #include<cstdio> #include<set> ...

  5. $POJ2311\ Cutting\ Game$ 博弈论

    正解:博弈论 解题报告: 传送门! 首先看到说,谁先$balabala$,因为$SG$函数是无法解决这类问题的,于是考虑转化成"不能操作者赢/输"的问题,不难想到先剪出$1\cdo ...

  6. 博弈问题之SG函数博弈小结

    SG函数: 给定一个有向无环图和一个起始顶点上的一枚棋子,两名选手交替的将这枚棋子沿有向边进行移动,无法移 动者判负.事实上,这个游戏可以认为是所有Impartial Combinatorial Ga ...

  7. 博弈论BOSS

    基础博弈的小结:http://blog.csdn.net/acm_cxlove/article/details/7854530 经典翻硬币游戏小结:http://blog.csdn.net/acm_c ...

  8. 【Mark】博弈类题目小结(HDU,POJ,ZOJ)

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 首先当然要献上一些非常好的学习资料: 基础博弈的小 ...

  9. [ACM_几何] Metal Cutting(POJ1514)半平面割与全排暴力切割方案

    Description In order to build a ship to travel to Eindhoven, The Netherlands, various sheet metal pa ...

随机推荐

  1. php5.4 的 arm 交叉编译

    ./configure --prefix=/h1root/usr/php --host=arm-linux --enable-libxml --with-mysql=mysqlnd --with-my ...

  2. Eclipse用了官方汉化后,无法输入

    解决方法:Rclipse右键→属性→兼容性→windows vista

  3. [LeetCode] 268. Missing Number ☆(丢失的数字)

    转载:http://www.cnblogs.com/grandyang/p/4756677.html Given an array containing n distinct numbers take ...

  4. .Net在线编辑器:KindEditor及CkEditor+CkFinder配置说明

    Net在线编辑器:KindEditor及CkEditor+CkFinder配置说明 一.KindEditor(免费) KindEditor是一套开源的HTML可视化编辑器,主要用于让用户在网站上获得所 ...

  5. 推荐八款.Net优秀的开源CMS 内容管理系统

    1,老牌内容管理系统SiteServer CMS  推荐指数:5 SiteServer CMS 是.NET平台的CMS系统,也是一款拥有十年历史与广泛知名度的CMS系统,2017年5月初迈出了自成立以 ...

  6. win7激活之系统保留分区的设置与隐藏

    激活动具:WIN7Activation_1.7 步骤: 1.直接点激活 2.若提示需设置驱动器号: 右键计算机-管理-磁盘管理-系统保留上点右键-更改驱动器号和路径-添加-点确定即可 3.激活win7 ...

  7. java修饰符的作用范围

    访问修饰符: private 缺省 protected public 作用范围: private 被private修饰的属性和方法,不能被其他类访问,子类不能继承也不能访问.只能在所在类内部访问.缺省 ...

  8. 《Python》 函数初识

    一.函数: 1.函数初识: def 关键字 函数名 # def my_len() 函数名的命名规则跟变量一样,要具有描述性. 函数的优点: 减少代码的重复率 增强代码的阅读性 函数的主要目的:封装一个 ...

  9. OPENVZ低版本centos6.5安装BBR加速手记

    玩 VPS,开机第一件事就是安装 BBR,至于效果怎么样还真不好说,依据不同的线路质量而定,但有总比没有好. 因为这次用的是 openvz 平台,所以找了一个网上的 ovz 专用的 BBR 一键安装代 ...

  10. rocketmq集群安装,配置,测试

    完整的安装包及demo请到百度云盘下载: 1.上传安装包 2.解压安装包 创建目录rocketmq mkdir -p /apps/install/rocketmq 解压到目录rocketmq tar ...