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. lombok @Slf4j注解

    背景知道有这么个东西,是因为项目中用到了@Slf4j注解. lombok库提供了一些注解来简化java代码 官网:http://projectlombok.org/ 查看lombok所有api:htt ...

  2. Taking water into exams could boost grades 考试带瓶水可以提高成绩?

    Takeing a bottle of water into the exam hall could help students boost their grades, researchers cla ...

  3. sql根据年月日查询注册数或者和值

    //公司需要我做一个根据每天用户注册数量生成一个折现图,sql如下,//亲测好用,只是如果某一天没有注册的话,就不会显示日期 SELECT DATE_FORMAT(f.registDate, '%Y- ...

  4. Android 音视频深入 一 AudioRecord录音生成pcm转换为wav(附源码下载)

    本篇项目地址,名字是AudioRecord录音(能暂停,将pch转换为wav),求starhttps://github.com/979451341/Audio-and-video-learning-m ...

  5. 获取音、视频时长(NAudio,Shell32,FFmpeg)

    参考网址:https://blog.csdn.net/u013810234/article/details/57471780 以下为本次测试用到的音.视频格式: audio :”.wav;.mp3;. ...

  6. U启动制作U盘启动盘详细教程

    第一步 打开u启动装机版,将准备好的u盘插入电脑usb接口并静待软件对u盘进行识别,由于此次u启动采用全新功能智能模式,可为u盘自动选择兼容性强与适应性高的方式进行制作,相较过去版本可省去多余的选择操 ...

  7. U帮忙U盘装系统工具使用教程

    在用U盘装系统时首先我们需要了解一下U帮忙U盘启动盘的制作以及BIOS设置U盘启动和U盘装系统步骤后才能让操作更顺利的完成,下面就来说说U帮忙U盘装系统工具使用教程,希望对大家有所帮助! 如果您不了解 ...

  8. linux:NFS

    1.简介 2.安装 安装分为服务端和客户端 [1]我们先拿一台机做服务端 yum install nfs-utils rpcbind -y 然后我们查查看安装没有,查询一个包是否被安装# rpm -q ...

  9. Docker安装websphere(四)

    在Docker容器里安装webshpere <!--前提:已经安装好了docker,能够正常使用.--> (1)docker安装websphere(需要账号和密码登录,不挂载数据卷) 获取 ...

  10. Maven 加载ojdbc14.jar报错,解决方法

    因为oracle的ojdbc.jar是收费的,所以maven的中央仓库中没有这个资源,只能通过配置本地库才能加载到项目中去. 首先下载 ojdbc14  https://pan.baidu.com/s ...