Idea: Water problem
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int MAXN =;
Char MM[MAXN][MAXN];
int main ()
{
int n,m,t;
int cas = 1;
scanf ("%d", &t);
while (t--)
{
int k = 0;
scanf ("%d%d", &n,&m);
for (int i = 0;i<n;i++)
scanf ("%s", Mm[i]);
for (int i = 0;i<n;i++) for
(int j = 0;j<m;j++)
if (mm[i][j]== ' O ')
k++;
printf ("Case%d:", cas++);
if (k%2==0)
printf ("Fat brother\n");
else
printf ("maze\n");
}
Description
Fat brother and Maze are playing a kind of special (hentai) game on a n*m board (N rows, M columns). At the beginning, there are n*m coins and board with two symbol "O" or "X". Then They take turns to choose a grid with symbol "O" and change it into "X". The game ends is the symbols in the board are "X", and the the one who cannot the her of play in his (turns) loses. Fat brother and Maze like this kind of the Ooxx game very much of the IT day and night. They don ' t even need a little rest after each game!
Here ' s the problem:who'll win the game if both use the best strategy? You can assume that Maze always goes a.
Input
Then T cases Follow, each case contains two integers N and M indicate the size of the board. Then goes N line, the "the" and "character" shows the state of the board.
1 <= T <=100, 1 <= n <=100, 1 <= m <=100
Output
For each case, output the case number then output the winner ' s name, either Fat brother or Maze. The sample input and output for more details.
Sample Input to 4oxxx2 4ooxxooxx1 2XX
Sample Output case 1:mazecase 2:fat brothercase 3:fat Brother