A - Matrix Game

Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu

Submit Status

Description

Given an m x n matrix, where m denotes the number of rows and n denotes the number of columns and in each cell a pile of stones is given. For example, let there be a 2 x 3 matrix, and the piles are

2 3 8

5 2 7

That means that in cell(1, 1) there is a pile with 2 stones, in cell(1, 2) there is a pile with 3 stones and so on.

Now Alice and Bob are playing a strange game in this matrix. Alice starts first and they alternate turns. In each turn a player selects a row, and can draw any number of stones from any number of cells in that row. But he/she must draw at least one stone. For example, if Alice chooses the 2nd row in the given matrix, she can pick 2 stones from cell(2, 1), 0 stones from cell (2, 2), 7 stones from cell(2, 3). Or she can pick 5 stones from cell(2, 1), 1 stone from cell(2, 2), 4 stones from cell(2, 3). There are many other ways but she must pick at least one stone from all piles. The player who can't take any stones loses.

Now if both play optimally who will win?

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing two integers: m and n (1 ≤ m, n ≤ 50). Each of the next m lines containsn space separated integers that form the matrix. All the integers will be between 0 and 109 (inclusive).

Output

For each case, print the case number and 'Alice' if Alice wins, or 'Bob' otherwise.

Sample Input

2

2 3

2 3 8

5 2 7

2 3

1 2 3

3 2 1

Sample Output

Case 1: Alice

Case 2: Bob

将每一行进行异或 所得结果ans如果不为0先手赢 否则后手赢

```#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
;
cin>>t;
while(t--)
{
;
cin>>m>>n;
;i<m;i++)
{
;
;j<n;j++)
{
cin>>data;
sum+=data;
}
ans^=sum;
}
if(ans)
printf("Case %d: Alice\n",cas++);
else
printf("Case %d: Bob\n",cas++);
}

;
}```

## LightOJ 1247 Matrix Game (尼姆博弈)的更多相关文章

1. Light OJ 1393 Crazy Calendar (尼姆博弈)

C - Crazy Calendar Time Limit:4000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Su ...

2. hdu----(1849)Rabbit and Grass（简单的尼姆博弈）

Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

3. hdu 1849（Rabbit and Grass） 尼姆博弈

Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

4. Being a Good Boy in Spring Festival 尼姆博弈

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

5. HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)

Climbing the Hill Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Su ...

6. Light OJ 1253 Misere Nim （尼姆博弈（2））

LightOJ1253 :Misere Nim 时间限制:1000MS    内存限制:32768KByte   64位IO格式:%lld & %llu 描述 Alice and Bob ar ...

7. hdu-------(1848)Fibonacci again and again(sg函数版的尼姆博弈)

Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

8. BestCoder Round #65 hdu5591（尼姆博弈）

ZYB's Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

9. hdu 1849 （尼姆博弈）

http://acm.hdu.edu.cn/showproblem.php? pid=1849 简单的尼姆博弈: 代码例如以下: #include <iostream> #include ...

## 随机推荐

1. Python之路【第六篇】python基础 之面向对象（一）

一.三大编程范式 1.面向过程编程 2.函数式编程 3.面向对象编程 二.编程进化论 1.编程最开始就是无组织无结构,从简单控制流中按步写指令 2.从上述的指令中提取重复的代码块或逻辑,组织到一起(比 ...

2. 理解Docker（2）：Docker 镜像

本系列文章将介绍Docker的有关知识: (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 ...

3. Mongodb学习笔记一(Mongodb环境配置)

Mongodb学习 说明: MongoDB由databases组成,database由collections组成,collection由documents组成,document由fileds组成.Mo ...

4. PL_SQL导入数据库数据

首先用pl/sql将数据批量导出或者全部导出具体操作如下 点击工具 ----->导出数据---->SQL插入 导出的数据格式如下:   prompt PL/SQL Developer im ...

5. SQL 高效分页查询

declare @page int --页码 declare @pagecount int;--每一页显示的记录数 select * from (select *,row_number() over( ...

6. python入门练习题1

常见python入门练习题 1.执行python脚本的两种方法 第一种:给python脚本一个可执行的权限,进入到当前存放python程序的目录,给一个x可执行权限,如:有一个homework.py文 ...

7. [Jquery]导航菜单效果-纵向

\$( document ).ready( function(e){ var \$catCont = \$( ".cat-cont" );    //二级菜单div    var \$ca ...

8. Helloworld模块之内核makefile详解

Hello World 模块以及对应的内核makefile详解 hello.c: #include <linux/module.h> //所有模块都需要的头文件 #include < ...

9. C# WinForm中 让控件全屏显示的实现代码

夏荣全 ( lyout(at)163.com )原文 C#中让控件全屏显示的实现代码(WinForm) 有时候需要让窗口中某一块的内容全屏显示,比如视频播放.地图等等.经过摸索,暂时发现两种可行方法, ...

10. 修改ie版本的注册表webbroswer

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Exp ...