OOXX Game

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, there are N*M coins in this 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 when all the symbols in the board are “X”, and the one who cannot play in his (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 will win the game if both use the best strategy? You can assume that Maze 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 contains two 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 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 Input

3 1 4 OXXX 2 4 OOXX OOXX 1 2 XX

Sample Output

Case 1: Maze Case 2: Fat brother Case 3: Fat brother
 #include <stdio.h>
#include <string.h> int main()
{
int n,m;
int T,ca=;
int i,j,k;
char s[];
scanf("%d",&T);
while(T--)
{
int num=;
scanf("%d %d",&n,&m);
for(i=;i<=n;i++)
{
scanf("%s",s);
for(j=;j<m;j++)
if(s[j]=='O')
num++;
}
printf("Case %d: ",ca);
if(num%==)
printf("Fat brother\n");
else
printf("Maze\n");
ca++;
}
return ;
}

FZU 2151 OOXX Game的更多相关文章

  1. FZU 2150 Fire Game

    Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit St ...

  2. ACM: FZU 2150 Fire Game - DFS+BFS+枝剪 或者 纯BFS+枝剪

    FZU 2150 Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  3. FZU 2144 Shooting Game

    Shooting Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  4. (FZU 2150) Fire Game (bfs)

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=2150 Problem Description Fat brother and Maze are playing ...

  5. FZU 2150 Fire Game(点火游戏)

    FZU 2150 Fire Game(点火游戏) Time Limit: 1000 mSec    Memory Limit : 32768 KB Problem Description - 题目描述 ...

  6. (广搜)Fire Game -- FZU -- 2150

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82828#problem/I Fire Game Time Limit:1000MS    ...

  7. FZU 2137 奇异字符串 后缀树组+RMQ

    题目连接:http://acm.fzu.edu.cn/problem.php?pid=2137 题解: 枚举x位置,向左右延伸计算答案 如何计算答案:对字符串建立SA,那么对于想双延伸的长度L,假如有 ...

  8. FZU 1914 单调队列

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=1914 题意: 给出一个数列,如果它的前i(1<=i<=n)项和都是正的,那么这个数列是正的,问这个 ...

  9. ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】

     FZU 2105  Digits Count Time Limit:10000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

随机推荐

  1. 【py网页】sitecopy代码

    001 #coding:utf-8 002 import re,os,shutil,sys 003 import urllib2,socket,cookielib 004 from threading ...

  2. json_encode注意

    PHP5.2或以上的版本把json_encode作为内置函数来用,但只支持utf-8编码的字符,否则中文就会出现乱码或者空值.解决办法如下: 1.保证在使用JSON处理的时候字符是以UTF8编码的.具 ...

  3. Android横竖屏切换继续播放视频

    只需要重新onSaveInstanceState方法,在其里面记住我们要记录的参数 package com.bawei.day07_videoview; import android.os.Bundl ...

  4. android 项目学习随笔二(引导页 )

    1.引导页 1.定义灰色.红色圆点的shape XML文件 2.定义布局文件,利用相对布局文件定位,利用线性布局加载灰色圆点,imageview加载红色圆点 3.android.support.v4. ...

  5. resultMap / resultType

    ===================resultMap:实体类的属性和通过resultMap映射后的property属性一致 <resultMap id="workerSelect& ...

  6. Linux之sed命令详解

    简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的 ...

  7. javaWeb 使用cookie显示商品浏览记录

    package de.bvb.cookie; import java.io.IOException; import java.io.PrintWriter; import java.util.Date ...

  8. Dynamics AX 2012 R2 Business Connector Error

    6.0: AxCryptoClient - New encryption key created 6.0: Unable to InitializeSession. 6.0: No built-in ...

  9. Caused by: javax.xml.bind.JAXBException: standardPremiumUpdateMessageDTO is not a valid property on

    Caused by: javax.xml.bind.JAXBException:  standardPremiumUpdateMessageDTO is not a valid property on ...

  10. C#:WiFi

    写的一个简单启动关闭WiFi的类:具体如下 using System; using System.Collections.Generic; using System.Text; using Syste ...