2011 was a crazy year. Many people all over the world proposed on 11-11-11, married on 11-11-11, some even went through surgery only to have 11-11-11 as their child's birth date. How crazy people can be! Don't they see there is a "20" hidden? Then what to do? A very elegant solution came from ARR, a very famous and funny character - why do we need to follow Christian (or some calls it Gregorian) calendar? Why don't we start our own calendar on the day of marriage? And those who like to celebrate their marriage ceremony too frequent, why don't they declare only 1 day per year. In that fashion they can celebrate their anniversary every day. And may be one minute a year or a second or ... Uh.. getting complex. Let's back to the title. From now, we start to have a new calendar system, "Kisu Pari Na". And we hope to update this calendar on every national contest.

The purpose of this calendar is - we all will try our best to learn something new in every year. For this first year let's learn some combinatory. It reminds me of my first year in college. I faced this problem but could not solve this then. But see how easy it is:

Say you start from upper left cell and want to go to lower right cell. The only restriction is you can only move downward or rightward. How many ways are there? How to solve it? Not that difficult. You have to go two times Down and three times Right (whichever way you try) to reach the goal from the starting cell, right? So the answer is number of ways you can arrange two D (represents Down) and three R (represent Right). 2 same characters and 3 same characters, total 5 characters. So it is:

Or = D+RCR. Easy isn't it?

Ok enough with learning. Now back to problem, given a grid and at each cell there are some coins. Inky and Pinky are playing a game getting inspiration from the above problem. At each turn, a player chooses a non empty cell and then removes one or more coins from that cell and put them to the cell exactly right of it or exactly beneath it. A player can't divide the coins and put one part to right and others to down. Note that, for the cells at the right column the player can't move it to more right, and same for the bottom-most row. So a player can't move coins from the lower right cell. The game will finish when no moves are available and the player who moved last will win. Now inky being very modest asked Pinky to move first. Can you say if Pinky will win if both play perfectly?

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing two integers R C (1 ≤ R * C ≤ 50000), where R denotes the number of rows and C denotes the number of columns of the grid respectively. Each of the next R lines contains C space separated integers denoting the grid. These integers lie in the range [0, 109].

Output

For every test case, output case number followed by "win" if Pinky can win or "lose".

Sample Input

1

2 2

1 1

1 1

Sample Output

Case 1: lose
/*
* @Author: lyuc
* @Date: 2017-04-25 20:23:56
* @Last Modified by: lyuc
* @Last Modified time: 2017-04-25 20:41:17
*/
/*题意:给你一个n*m的矩阵,每个格子里都有一定数量的石头,两个人轮流移动石头,每次选择一个格子,移动至少一个石头,
* 但是只能移动到右边一个,或者下边一个格子,谁不能移动了就输了。
*
*初步思路:如果这个格子到右下角的步数是偶数的话,那么就不用考虑这个格子了,因为如果是偶数,那么先手移动几个,后手
 * 就移动几个,这样就抵消了。所以只需要考虑奇数步数的格子,这就是一个简单的NIM博弈了
*//
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int t;
int n,m;
int num;
LL res;
int main(){
// freopen("in.txt","r",stdin);
scanf("%d",&t);
for(int ca=;ca<=t;ca++){
printf("Case %d: ",ca);
res=;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
scanf("%d",&num);
if(((n+m)-(i+j))%)
res^=num;
}
}
printf(res?"win\n":"lose\n");
}
return ;
}
 

Crazy Calendar (阶梯博弈变形)的更多相关文章

  1. HDU 4315 阶梯博弈变形

    n个棋子,其中第k个是红色的,每个棋子只能往上爬,而且不能越过.重叠其他棋子,谁将红色棋子移到顶部谁赢. 由于只能往上爬,所以很像阶梯博弈.这题有2个限制,棋子不能重叠,有红棋存在 首先不考虑红色棋, ...

  2. HDU 3389 阶梯博弈变形

    n堆石子,每次选取两堆a!=b,(a+b)%2=1 && a!=b && 3|a+b,不能操作者输 选石子堆为奇数的等价于选取步数为奇数的,观察发现 1 3 4 是无法 ...

  3. LightOJ 1393 Crazy Calendar(博弈)题解

    题意:r*c方格中,每个格子有一定石子,每次移动每格任意数量石子,只能向下或者向右动一格,不能移动为败 思路:显然是Nim,到右下曼哈顿距离为偶数的不用管,因为先手动一下后手动一下最后移到右下后还是先 ...

  4. Light OJ 1393 Crazy Calendar (尼姆博弈)

    C - Crazy Calendar Time Limit:4000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Su ...

  5. hdu4318阶梯博弈nim变形

    阶梯博弈原理参考:http://www.cnblogs.com/jiangjing/p/3849284.html 这题计算每两个之间的间隔就行了,如果是奇数个就把第一个前面的看作一个,偶数个就是两个点 ...

  6. HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)

    Climbing the Hill Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Su ...

  7. POJ1704 Georgia and Bob (阶梯博弈)

    Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u Subm ...

  8. HDU 4315:Climbing the Hill(阶梯博弈)

    http://acm.hdu.edu.cn/showproblem.php?pid=4315 题意:有n个人要往坐标为0的地方移动,他们分别有一个位置a[i],其中最靠近0的第k个人是king,移动的 ...

  9. hdu 3389 Game (阶梯博弈)

    #include<stdio.h> int main() { int t,n,ans; int i,j,x; scanf("%d",&t); ;j<=t; ...

随机推荐

  1. 基于nodejs+webSocket的聊天室(实现:加入聊天室、退出聊天室、在线人数、在线列表、发送信息、接收信息)

    1  安装 socket.io模块 npm install "socket.io": "latest" 2 app.js相关 ws = require('soc ...

  2. 有关 Hybrid 开发模式实践总结

    前言 随着公司业务不断发展,移动开发项目越来越多,项目任务时间紧,我们内部开发流程是以项目为导向,有别于一般公司对产品不断迭代的做法,但移动端开发人员资源有限,需要在不同项目之间做业务场景切换开发,就 ...

  3. Hadoop(四)HDFS集群详解

    前言 前面几篇简单介绍了什么是大数据和Hadoop,也说了怎么搭建最简单的伪分布式和全分布式的hadoop集群.接下来这篇我详细的分享一下HDFS. HDFS前言: 设计思想:(分而治之)将大文件.大 ...

  4. Color Blender---在线渐变色带生成器

       Color Blender是一个很有用的在线渐变色带生成器,它可以在两种颜色之间,自动生成过渡色,对网页设计师来说是一个不错的颜色调配工具.   Color Blender的使用方法很简单,你只 ...

  5. 阿里巴巴Java规约插件试用

    阿里Java开发规约Eclipse插件介绍 阿里巴巴集团配合<阿里巴巴Java开发手册>PDF终极版开发的IDE插件,目前包括IDEA插件.Eclipse插件. 安装 检查环境 插件要求: ...

  6. python初步(附学习思维导图)

    python,原意为蟒蛇,至于它的发展史,度娘应该比我讲述的更为专业/偷笑.这里我们要梳理的是整个学习的脉络,当然,今后的随笔也会从基础部分说起,希望能给进门python的小伙伴一些建议. 一.环境的 ...

  7. IIS ApplicationPoolIdentity(配置IIS讀寫網站文件)

    原创地址:http://www.cnblogs.com/jfzhu/p/4067297.html 转载请注明出处 从IIS 7.5开始,Application Pool Identity的Built- ...

  8. win10 uwp 自定义控件初始化

    我遇到一个问题,我在 xaml 用了我的自定义控件,但是我给他设置了一个值,但是什么时候我才可以获得这个值? 本文告诉大家,从构造函数.loaded.Initialized 的调用过程. 用最简单的方 ...

  9. 最美时光第三方UWP源码公开

    自己大概写了一个星期的成果.. 使用了官方最美时光app的UI和图片资源,并没有调用官方接口 https://files.cnblogs.com/files/loyieking/NiceCountDo ...

  10. Unity Shader - 消融效果原理与变体

    基本原理与实现 主要使用噪声和透明度测试,从噪声图中读取某个通道的值,然后使用该值进行透明度测试. 主要代码如下: fixed cutout = tex2D(_NoiseTex, i.uvNoiseT ...