博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Crazy Calendar (阶梯博弈变形)
阅读量:7083 次
发布时间:2019-06-28

本文共 3862 字,大约阅读时间需要 12 分钟。

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 
#define LL long longusing namespace std;int t;int n,m;int num;LL res;int main(){ // freopen("in.txt","r",stdin); scanf("%d",&t); for(int ca=1;ca<=t;ca++){ printf("Case %d: ",ca); res=0; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ scanf("%d",&num); if(((n+m)-(i+j))%2) res^=num; } } printf(res?"win\n":"lose\n"); } return 0;}

 

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/6764256.html

你可能感兴趣的文章
Android 播放Gif 动画
查看>>
(原创)创建windows域---深入理解域概念
查看>>
虚幻4,BP写了一个简单的三线跑酷工程
查看>>
“10亿元身价”CEO的6个密码
查看>>
C++/CLI思辨录之内部指针的两面性
查看>>
【英语天天读】I want I do I get
查看>>
DIV层+CSS实现锁屏
查看>>
浅谈C/C++中的顺序点和副作用
查看>>
每周一书-《做自己-鬼脚七自媒体第一季》
查看>>
如何删除JAVA集合中的元素
查看>>
jQuery 事件 - trigger() 方法
查看>>
模态窗口被IE 7给糟蹋得不成样子了
查看>>
你不知道的Spring配置文件
查看>>
Spark源码分析之Spark-submit和Spark-class
查看>>
SOA系列之基本特性
查看>>
js中的"=="和equals()以及is()三者的区别
查看>>
谨慎注意WebBrowser控件的DocumentCompleted事件
查看>>
回头再说 005 --温暖的文字和音乐
查看>>
C#进行Visio二次开发之电气线路停电分析逻辑
查看>>
简便无刷新文件上传系统
查看>>