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. iOS实践03

    主要目标:版本新特性界面,新浪授权界面(登录界面)的处理 任务基本完成了,基本的框架也就到这了,接下来的应该是首页获取微博了. 1.版本新特性,可以单独作为一个model,写完之加入到项目中.我们新建 ...

  2. 使用Maven完成自动化打包并部署到Linux服务器下(Tomcat7)

    最近在使用maven,顺便尝试了下tomcat部署.网上找到了很多资料但是都不是最新的,所以贴上比较新的Tomcat7部署代码和配置,方便以后回顾-->测试OK. 1. 首先是配置Tomcat ...

  3. Session累计用户数据列表

    OrderForm.html <body>  <center>  <h1 ><font size="20">Order Items& ...

  4. News feed

    1. Level 1.0 Database Schema: a. User UserID Name Age 1 Jason 25 2 Michael 26 b. Friendship Friendsh ...

  5. Java 网络编程(二) 两类传输协议:TCP UDP

    链接地址:http://www.cnblogs.com/mengdd/archive/2013/03/09/2951841.html 两类传输协议:TCP,UDP TCP TCP是Transfer C ...

  6. mysql 存储过程需要DELIMITER

    DELIMITER &&CREATE PROCEDURE syncAdvertiser() BEGIN DECLARE id bigint; DECLARE _cur CURSOR F ...

  7. PHP的排列组合问题 分别从每一个集合中取出一个元素进行组合,问有多少种组合?

    首先说明这是一个数学的排列组合问题C(m,n) = m!/(n!*(m-n)!) 比如:有集合('粉色','红色','蓝色','黑色'),('38码','39码','40码'),('大号','中号') ...

  8. 在iOS上增加手势锁屏、解锁功能

    在iOS上增加手势锁屏.解锁功能 在一些涉及个人隐私的场景下,尤其是当移动设备包含太多私密信息时,为用户的安全考虑是有必要的. 桌面版的QQ在很多年前就考虑到用户离开电脑后隐私泄露的危险,提供了“离开 ...

  9. js 获取前天、昨天、今天、明天、后天的时间

    js 获取前天.昨天.今天.明天.后天的时间 2011-05-19 21:03   <html><head><meta http-equiv="Content- ...

  10. MVC 常用方法

    1. 后台 action方法里添加错误消息到字典中(key,value) ModelState.AddModelError("Error", "参数传输有误,请重新尝试! ...