Fliping game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 853    Accepted Submission(s): 612

Problem Description
Alice and Bob are playing a kind of special game on an N*M board (N rows, M columns). At the beginning, there are N*M coins in this board with one in each grid and every coin may be upward or downward freely. Then they take turns to choose a rectangle (x
1, y
1)-(n, m) (1 ≤ x
1≤n, 1≤y
1≤m) and flips all the coins (upward to downward, downward to upward) in it (i.e. flip all positions (x, y) where x
1≤x≤n, y
1≤y≤m)). The only restriction is that the top-left corner (i.e. (x
1, y
1)) must be changing from upward to downward. The game ends when all coins are downward, and the one who cannot play in his (her) turns loses the game. Here's the problem: Who will win the game if both use the best strategy? You can assume that Alice always goes first.
 
Input
The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each case starts with two integers N and M indicate the size of the board. Then goes N line, each line with M integers shows the state of each coin, 1<=N,M<=100. 0 means that this coin is downward in the initial, 1 means that this coin is upward in the initial.
 
Output
For each case, output the winner’s name, either Alice or Bob.
 
Sample Input
2
2 2
1 1
1 1
3 3
0 0 0
0 0 0
0 0 0
 
Sample Output
Alice
Bob

水题, 看最后一个数就行了, 是1, Alice赢, 是0, Bob赢~

AC代码:

#include<stdio.h>

int main() {
int T;
scanf("%d", &T);
while(T--) {
int r, c;
scanf("%d %d", &r, &c);
int key;
for(int i = 0; i < r; i++)
for(int j = 0; j < c; j++)
scanf("%d", &key);
if(key == 1)
printf("Alice\n");
else
printf("Bob\n");
}
return 0;
}

HDU 4642 (13.08.25)的更多相关文章

  1. HDU 4287 (13.08.17)

    Problem Description We all use cell phone today. And we must be familiar with the intelligent Englis ...

  2. UVA 10340 (13.08.25)

    Problem E All in All Input: standard input Output: standard output Time Limit: 2 seconds Memory Limi ...

  3. UVA 10041 (13.08.25)

     Problem C: Vito's family  Background The world-known gangster Vito Deadstone is moving to New York. ...

  4. UVA 639 (13.08.25)

     Don't Get Rooked  In chess, the rook is a piece that can move any number of squaresvertically or ho ...

  5. hdu 4642 Fliping game

    http://acm.hdu.edu.cn/showproblem.php?pid=4642 对于给定的矩阵 操作步数的奇偶性是确定的 奇数步Alice赢 否则Bob赢 从左上角向右下角遍历遇到1就进 ...

  6. hdu 4642 Fliping game(博弈)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4642 题意:给定一个棋盘,0表示向下,1表示向上,选一个x,y, 然后翻转从x,y 到n,m.的所有硬币, ...

  7. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  8. 百度地图-省市县联动加载地图 分类: Demo JavaScript 2015-04-26 13:08 530人阅读 评论(0) 收藏

    在平常项目中,我们会遇到这样的业务场景: 客户希望把自己的门店绘制在百度地图上,通过省.市.区的选择,然后加载不同区域下的店铺位置. 先看看效果图吧: 实现思路: 第一步:整理行政区域表: 要实现通过 ...

  9. Segment Tree 扫描线 分类: ACM TYPE 2014-08-29 13:08 89人阅读 评论(0) 收藏

    #include<iostream> #include<cstdio> #include<algorithm> #define Max 1005 using nam ...

随机推荐

  1. 关于js封装框架类库之选择器引擎(一)

    选择器模块之传统做法 var tag = function (tag){ return document.getElementsByTagName(tag); } var id = function ...

  2. 【原创】ASP.NET Web开发,实现打印Log日志,步骤详解

    添加Log需要四步: 一.引用log4net.dll,详见附件:http://pan.baidu.com/s/1c0hab2g 二.项目根目录下,添加 log4net.xml <?xml ver ...

  3. 在MySQL中创建实现自增的序列(Sequence)的教程

    这篇文章主要介绍了在MySQL中创建实现自增的序列(Sequence)的教程,分别列举了两个实例并简单讨论了一些限制因素,需要的朋友可以参考下 项目应用中,曾有以下一个场景: 接口中要求发送一个int ...

  4. poj 3259Wormholes (spfa最短路径)

    #include<stdio.h> #include<string.h> #include<limits.h> #include<queue> usin ...

  5. 【微信公众号】使用a标签打开链接显示空白

    window.location.href 改成 top.location.href

  6. 【转】DevExpress控件安装

    原文链接: DevExpress控件安装.汉化使用教程 - 田园里的蟋蟀 学习网址: 1.DevExpress控件中文网 2.DevExpress控件中文网使用教程 3.DevExpress控件使用经 ...

  7. 创建理想的SEQUENCE和自增长的trigger

    SEQUENCE CREATE SEQUENCE TEST_SEQ START 1 --从1开始,第一个一定是NEXTVAL,因为第一个CURRVAL不好使,返回值会是1,第一个NEXTVAL相当于从 ...

  8. widget intent重复问题

    今天在做android widget时发现点击任意widget时只会更新最后一个widget 原来是requestCode的问题 Intent intent = new Intent(WidgetPr ...

  9. 高质量程序设计指南C/C++语言——C++/C常量(2)

  10. ForeignKey.on_delete

    当由一个 ForeignKey 引用的对象被删除,默认情况下,Django模拟SQL的 ON DELETE CASCADE 来删除对象的 ForeignKey 关系.这样可以覆盖指定的 on_dele ...