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. hasOwnProperty和isPrototypeOf方法使用

    hasOwnProperty():判断对象是否有某个特定的属性.必须用字符串指定该属性.(例如,o.hasOwnProperty("name"))  //复制自w3cschool ...

  2. Node.js、Ionic、Cordova、AngualrJS安装

    1.安装node.js: 从node.js官网下载node.js安装包,node.js下载地址:https://nodejs.org/en/download/,选择对应系统的安装下载后进行安装.(注: ...

  3. GDI+ 对象释放崩溃的问题

    确保在Gdiplus::GdiplusShutdown(m_gdiplusToken); 之前delete 掉GDI+的对象,例如:delete *pBitmap; 如果先Gdiplus::Gdipl ...

  4. ButterKnife 绑定 RadioGroup

    原则上 ButterKnife 是不支持 RadioGroup 的, 可以通过以下方法添加RadioButton的点击事件: @OnClick({ R.id.radio_btn1, R.id.radi ...

  5. 数据库导出到excel

    项目结构同上一篇 泛型通用的写法 ExportExcel.java package excel; import java.io.OutputStream; import java.lang.refle ...

  6. Python正则表达式一: 基本使用方法

    学习python的正则表达式,主要有两个方面学习: 第一,学习如何写正则表达式,主要是掌握其语法规范.正则表达式的语法规范是通用的,对各种开发语言都是一致的. 第二,学习如何使用正则表达式,也就是掌握 ...

  7. COM编程之IUnknown接口

    COM组件其实是一种特殊的类,遵循一个统一的标准,使到各个软件都可以通过某种方法访问这个类的函数和方法,也就可以做到组件通用. com就是统一的标准--通过接口来调用com组件.接口是你的com组件能 ...

  8. mget 同时获取

    mget 同时获取: http://192.168.32.81:9200/ _mget POST { "docs" :[ { "_index":"li ...

  9. 移动服务和 Azure Active Directory 中基于角色的访问控制

    编辑人员注释:本文章由 Matthew Henderson撰写 去年 11月,我们发布了 Azure Active Directory (AAD) 预览版作为移动服务身份提供程序.此举旨在为企业开 ...

  10. Android测试TestSuite的执行方法

    public class StartTest extends InstrumentationTestRunner {         public  TestSuite getAllTests() { ...