题意

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. secs/gem协议

    介绍SECS/GEM SEMI SECS/GEM标准概述 SECS/GEM是由国际半导体设备与材料协会(SEMI)制定的连接性标准.此连接性标准用于在设备和工厂的资讯和控制系统间建立通讯. SECS是 ...

  2. English trip V1 - 3.What Would you Like? Teacher:Lamb Key: would like to

    In this lesson you will learn to talk about fast food and health. would = will 的过去式 STARTER 1.Tell y ...

  3. C++&C#外挂(内存修改)

    大学时候因为主修C#语言(当然现在做的是javaweb开发),那时在网上学了用C#做外挂的教程,外挂嘛,大家都懂的.这里只是低级的修改内存,不涉及到截获数据包.如果是欺骗服务器,修改服务器数据,那就难 ...

  4. Sonya and Ice Cream CodeForces - 1004E 树的直径, 贪心

    题目链接 set维护最小值贪心, 刚开始用树的直径+单调队列没调出来... #include <iostream>#include <cstdio> #include < ...

  5. DIV字体

    1.如何设定文字字体.颜色.大小 —— 使用font font-style设定斜体,比如font-style: italicfont-weight设定文字粗细,比如font-weight: bold; ...

  6. JavaScript学习总结(八)——JavaScript数组

    JavaScript中的Array对象就是数组,首先是一个动态数组,无需预先制定大小,而且是一个像Java中数组.ArrayList.Hashtable等的超强综合体. 一.数组的声明 常规方式声明: ...

  7. sql server2008 如何获取上月、上周、昨天、今天、本周、本月的查询周期(通过存储过程)

    我这边有一个需求要统计订单数据,需要统计订单的上传日期,统计的模块大概是 那么上月.上周.昨天.今天.本周.本月应该是怎样呢? 1.数据分析 因为今天是动态数据,我要查月份(上月.本月),应该是一个日 ...

  8. PHP:第三章——PHP中返回引用的函数

    <?php header("Content-Type:text/html;charset=utf-8"); $i=1; function &F(){ global $ ...

  9. PHP:第一章——按位运算和求余运算(判断奇偶数)

    <?php //按位运算:与1按位运算等于0,输出偶数.如果等于1,输出奇数 //输出偶数: for($i=0;$i<10;$i++){ if(($i & 1)==0){ echo ...

  10. 【译】MVC3 20个秘方-(15)使用CAPTCHA去防止恶意软件自动提交评论(防灌水)

    [译]MVC3 20个秘方-(15)使用CAPTCHA去防止恶意软件自动提交评论(防灌水)   问题 有种不太幸运的情况,有人用自动程序去提交表单,在整个互联网中造成大量的垃圾.为了防止这种情况的方法 ...