题目:
http://acm.hdu.edu.cn/showproblem.php?pid=4642
题意:
给你一个n*m的矩阵,上面有正面或者反面的棋子, 每一次只能选(x,y)正面的棋子进行翻转, 区域(x,y)-(n,m) 中的棋子都会被翻转. A,B一块玩, A先,最后要使得所有的棋子都是反面的. 求出谁会赢得比赛.
思路:
博弈.
因为每一次翻转都会翻到格子(n,m), 最后要使得所有棋子都是反面的,则一开始(n,m)是正面的话则翻奇数次, 则A赢. 若是反面的则翻偶数次, 则B赢.
AC.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int mapa[105][105];
int main()
{
int t,n,m;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
int i,j;
for(i = 1; i <= n; i++)
for(j = 1; j <= m; j++)
scanf("%d",&mapa[i][j]);
if(!mapa[n][m])
printf("Bob\n");
else
printf("Alice\n");
}
return 0;
}