HDOJ 4642 Fliping game
来源:互联网 发布:姚明职业生涯平均数据 编辑:程序博客网 时间:2024/06/05 02:44
Fliping game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1770 Accepted Submission(s): 1157
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.
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
22 21 11 13 30 0 00 0 00 0 0
Sample Output
AliceBob
题意就是一局游戏,在n*m的棋盘里面有硬币,分为朝上或者朝下,每个人可以选择一个x,y,翻转x到n,y到m的硬币,求最后谁能获胜。
很少做博弈论,其实这个题很简单,每次翻转时都会把n,m的硬币翻转,要使最后nm==1;
如果输入nm为0那么就肯定需要奇数次,反之就需要偶数次。(我还是太年轻)
#include<stdio.h>#include<algorithm>#include<string>#include<string.h>#include<queue>#include<stack>#include<math.h>using namespace std;int main(){ int a[105][1005]; int n,m,t; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) scanf("%d",&a[i][j]); } if(a[n][m]==1) printf("Alice\n"); else printf("Bob\n"); }return 0;}
0 0
- HDOJ 4642 Fliping game
- HDOJ 4642 Fliping game
- HDOJ 4642 Fliping game
- (博弈)Fliping game--HDOJ
- HDU 4642 Fliping game
- hdu 4642 Fliping game
- HDU 4642 Fliping game
- HDU-4642-Fliping game
- HDU 4642 Fliping game
- HDU 4642 - Fliping game(博弈)
- HDU 4642 Fliping game 解题报告
- HDU 4642 Fliping game (博弈)
- hdu 4642 Fliping game(博弈)
- hdu - 4642 - Fliping game(博弈)
- hdu 4642 Fliping gameFliping game (博弈论)
- HDU 4642 Fliping game(简单博弈)
- hdu 4642 Fliping game(博弈)
- HDU 4642 Fliping game (简单博弈)
- C语言代码4(求最大公约数)
- Redis 主从 Replication 的配置
- JZOJ 4821. 【NOIP2016提高A组模拟10.15】打膈膜
- JAVA代码执行顺序
- jzoj4819 算循环
- HDOJ 4642 Fliping game
- iBatis2学习笔记:SqlMap的配置总结(18条)
- android绘制实心圆、空心圆
- Redis Sentinel机制与用法(一)
- VS2008调试技术
- HDU ACM 11 2040 亲和数
- wamp 的Redis 环境搭建以及phpredis扩展
- UVA 11996 Splay + LCP + Hash + 区间翻转 插入 删除
- Redis Sentinel 机制与用法(二)