Fzu 2151 Ooxx game__ water problem

Source: Internet
Author: User
Tags cas

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.