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,  那么自己就还能取。 如果后者已经没得取了, 那么自己就已经赢了。
 
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int n,m;
  9.  
  10. int main(){
  11.  
  12. //freopen("input.txt","r",stdin);
  13.  
  14. int t;
  15. scanf("%d",&t);
  16. while(t--){
  17. scanf("%d%d",&n,&m);
  18. int x;
  19. for(int i=;i<n;i++)
  20. for(int j=;j<m;j++)
  21. scanf("%d",&x);
  22. if(x)
  23. puts("Alice");
  24. else
  25. puts("Bob");
  26. }
  27. return ;
  28. }

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. shell 通配符

    Bash中的通配符 '?' 匹配一个任意字符 '*' 匹配0个或任意多个字符,也就是可以匹配任何内容 '[]' 匹配括号中任意一个字符.例如[abc]代表一定匹配一个字符,或者是a,或者是b,或者是c ...

  2. centos7.0 64位系统 安装PHP5.3 支持 nginx

    1  安装PHP所需要的扩展 yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl cur ...

  3. RabbitMQ进阶使用-延时队列的配置(Spring Boot)

    依赖 MAVEN配置pom.xml <dependency> <groupId>org.springframework.boot</groupId> <art ...

  4. day06 元组类型

    一.什么是元组? 元组就是一个不可变的列表 元组的基本使用: 1.用途:  用于存放多个值,当存放多个任意类型的值 2.定义方式:在()内用逗号分隔开多个任意类型的值 t=(1,3.1,'aaa',( ...

  5. OO第四次课程总结分析

    OO第四次课程总结分析 测试与正确性论证的效果差异及优缺点 测试,即使用测试样例来验证我们的程序是否能完成相应功能的过程.测试数据的产生基于前置条件和后置条件,通过执行测试数据检查方法输出是否满足需求 ...

  6. JDBC连接数据库:单线程、多线程、批处理插入数据的对比

    一.单线程(单条循环)插入50000条记录: 每执行一次就要访问一次数据库 import java.sql.Connection; import java.sql.DriverManager; imp ...

  7. 每天CSS学习之box-shadow

    box-shadow是CSS3的属性,目的是给盒子添加一个或多个阴影.怎么感觉有点像光明使者使用该法术照亮敌人的阴暗面? box-shadow一共有六个属性,请看: box-shadow: h-sha ...

  8. 学习net core的一些疑问?

    所有的内容是否一定都要依赖注入? 获取配置文件的方式是否在类库是获取不到环境变量的? 老出现:InvalidOperationException: Unable to resolve service ...

  9. Convert the AScii to SAC file

    readtable *.txt w sac  filename.sac ch delta dela0 w over

  10. 更改centos源为aliyun

    完全参考 http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD 1.备份 mv /etc/yum.repos.d/C ...