Fzu problem 2151 Ooxx Game (math AH)

Source: Internet
Author: User

Title Link: http://acm.fzu.edu.cn/problem.php?pid=2151


Problem Description

Fat brother and Maze is playing a kind of special (hentai) game on an n*m board (N rows, M columns). At the beginning, there is n*m coins in this board with the symbol "O" or "X". Then they take turns to choose a grid with symbol "O" and change it into "X". The game ends when all the symbols in the board is "X", and the one who cannot play in he (her) turns loses the game. Fat brother and Maze like this kind of ooxx game very much and play it day and night. They don ' t even need a little rest after each game!

Here's the problem:who would win the game if both use the best strategy? You can assume this Maze always goes first.

Input

The first line of the date is a integer T, which is the number of the text cases.

Then T cases follow, each case contains the integers N and M indicate the size of the board. Then goes N line, each line with M character shows the state of the board.

1 <= T <=100, 1 <= n <=100, 1 <= m <=100

Output

For each case, output of the case number first, and then output the winner ' s name, either Fat brother or Maze. See the sample, input and output for more details.

Sample Input31 4oxxx2 4ooxxooxx1 2XX sample outputcase 1:mazecase 2:fat brothercase 3:fat Brother

The code is as follows:

#include <cstdio>const int MAXN = 117;char Mm[maxn][maxn];int main () {    int n,m;    int t;    int cas = 0;    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");    }    return 0;}


Fzu problem 2151 Ooxx Game (math AH)

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.