Fliping game

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

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 (x1, y1)-(n, m) (1 ≤ x1≤n, 1≤y1≤m) and flips all the coins (upward to downward, downward to upward) in it (i.e. flip all positions (x, y) where x1≤x≤n, y1≤y≤m)). The only restriction is that the top-left corner (i.e. (x1, y1)) 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
 
Source
 
Recommend
zhuyuanchen520
 

签到题,可是却没仔细理解题意,导致没签到成功,这是病,得治。

思路:
最后一个格子是会被任意格子影响的。
每次只要保证自己取完后, 最后一个格子是0, 就不会输。
因为: 对于后者如果还能取,最后一个格子肯定会变成1,  那么自己就还能取。 如果后者已经没得取了, 那么自己就已经赢了。
 
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> using namespace std; int n,m; int main(){ //freopen("input.txt","r",stdin); int t;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
int x;
for(int i=;i<n;i++)
for(int j=;j<m;j++)
scanf("%d",&x);
if(x)
puts("Alice");
else
puts("Bob");
}
return ;
}

HDU 4642 Fliping game (简单博弈)的更多相关文章

  1. HDU 4642 Fliping game (2013多校4 1011 简单博弈)

    Fliping game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  2. hdu 4642 Fliping game(博弈)

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

  3. hdu 4642 Fliping game

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

  4. HDU 1079 Calendar Game(简单博弈)

    Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  5. HDU-4642 Fliping game 简单博弈

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4642 看右下角的状态就行了,因为上面的操作每次都会改变它,而最后的局势是根据它来的... //STAT ...

  6. hdu 1846 Brave Game 简单博弈

    Problem Description 十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫<勇敢者的游戏>(英文名称:Zathura),一直到现在,我依然对于电影中 ...

  7. 【多校练习4签到题】HDU 4642—— Fliping game

    来源:点击打开链接 看上去很难,比赛的时候光看hehe了,也没有想. 但是仔细想想,是可以想出来的.一个棋盘上每个格子摆放一个硬币,硬币有正面1和反面0之分.现在两个人可以按照规则翻硬币,选择(x,y ...

  8. hdu 2149 Public Sale 简单博弈

    Problem Description 虽然不想,但是现实总归是现实,Lele始终没有逃过退学的命运,因为他没有拿到奖学金.现在等待他的,就是像FarmJohn一样的农田生涯.要种田得有田才行,Lel ...

  9. HDU 1564 简单博弈 水

    n*n棋盘,初始左上角有一个石头,每次放只能在相邻的四个位置之一,不能操作者输. 如果以初始石头编号为1作为后手,那么对于每次先手胜的情况其最后一步的四周的编号必定是奇数,且此时编号为偶数,而对于一个 ...

随机推荐

  1. 学习笔记-AngularJs(三)

    学习笔记-AngularJs(二)写了个所有程序语言入门时都必须要写的Hello World,那么从现在开始做那个之前说过的互联网大佬介绍的学习例子,当然这里开始会慢慢按照之前说过的目录来搭建这个学习 ...

  2. VS中常用快捷键

    常用的快捷键     这里仅列出一些个人觉得好用的快捷键: 调用智能提示:使用组合键“Ctrl+J” 注释/取消注释: 注释用组合键“Ctrl+K+C” 取消注释用组合键“Ctrl+K+U” 大小写转 ...

  3. Android 音视频深入 四 录视频MP4(附源码下载)

    本篇项目地址,名字是<录音视频(有的播放器不能放,而且没有时长显示)>,求star https://github.com/979451341/Audio-and-video-learnin ...

  4. String常用方法

    1. String StringBuffer StringBuilder的区别: 001.在执行速度方法 StringBuilder > StringBuffer > String 002 ...

  5. svn服务器搭建及使用(三)

    接下来,试试用TortoiseSVN修改文件,添加文件,删除文件,以及如何解决冲突等. 添加文件 在检出的工作副本中添加一个Readme.txt文本文件,这时候这个文本文件会显示为没有版本控制的状态, ...

  6. (C/C++学习笔记) 一. 基础知识

    一. 基础知识 ● 程序和C/C++ 程序: 根据Wirth (1976), Algorithms + Data Structures = Programs. Whence C: 1972, Denn ...

  7. 1040 有几个PAT

    字符串 APPAPT 中包含了两个单词 PAT,其中第一个 PAT 是第 2 位(P),第 4 位(A),第 6 位(T):第二个 PAT 是第 3 位(P),第 4 位(A),第 6 位(T). 现 ...

  8. easyui弹框后销毁当前tab弹框不显示的解决方式

    var id=$("#pageId").val(); var message = "{\"id\":" + id+ ",\&quo ...

  9. L291

    If you are currently in the midst of planning a wedding, then I don't need to tell you how stressful ...

  10. JavaServlet的文件上传和下载

    关于JSP中的文件上传和下载操作 先分析一下上传文件的流程 1-先通过前段页面中的选择文件选择要上传的图片 index.jsp <%@ page language="java" ...