题意:

给一个矩阵,每一次一个玩家可以从任意一行中选任意数量的格子并从中拿石头(但最后总数要大于等于1),问你谁赢

思路:

一开始以为只能一行拿一个...

将每一行石子数相加就转化为经典的Nim博弈

代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
const int N = 100000+5;
const int INF = 0x3f3f3f3f;
using namespace std;
int main() {
int T,m,n,a,Case = 1;
scanf("%d",&T);
while(T--){
scanf("%d%d",&m,&n);
int ans = 0;
for(int i = 0;i < m;i++){
int sum = 0;
for(int i = 0;i < n;i++){
scanf("%d",&a);
sum += a;
}
ans ^= sum;
}
if(ans == 0) printf("Case %d: Bob\n",Case++);
else printf("Case %d: Alice\n",Case++);
}
return 0;
}

LightOJ - 1247 Matrix Game (Nim博弈)题解的更多相关文章

  1. LightOJ 1186 Icreable Chess(Nim博弈)

    You are given an n x n chess board. Only pawn is used in the 'Incredible Chess' and they can move fo ...

  2. LightOJ 1247 Matrix Game (尼姆博弈)

    A - Matrix Game Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submi ...

  3. LightOJ 1253 Misere NIM(反NIM博弈)

    Alice and Bob are playing game of Misère Nim. Misère Nim is a game playing on k piles of stones, eac ...

  4. nim博弈 LightOJ - 1253

    主要是写一下nim博弈的理解,这个题有点奇怪,不知道为什么判断奇偶性,如果有大佬知道还请讲解一下. //nim博弈 //a[0]~a[i] 异或结果为k 若k=0 则为平衡态 否则为非平衡态 //平衡 ...

  5. codeforces 812E Sagheer and Apple Tree(思维、nim博弈)

    codeforces 812E Sagheer and Apple Tree 题意 一棵带点权有根树,保证所有叶子节点到根的距离同奇偶. 每次可以选择一个点,把它的点权删除x,它的某个儿子的点权增加x ...

  6. POJ2234:Matches Game(Nim博弈)

    Matches Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12325   Accepted: 7184 题目链 ...

  7. hdu2509Be the Winner(反nim博弈)

    Be the Winner Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  8. hdu1907John(反nim博弈)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  9. hdu1730Northcott Game(nim博弈)

    Northcott Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

随机推荐

  1. shidebing——QandA:解决一个需求20171214

    list1 = [ {'eip': 60, 'day': '2014-7-5'}, {'etans': 96, 'day': '2014-7-5'}, {'etans': 30, 'day': '20 ...

  2. SQL SERVER 聚集索引 非聚集索引 区别

    转自http://blog.csdn.net/single_wolf_wolf/article/details/52915862 一.理解索引的结构 索引在数据库中的作用类似于目录在书籍中的作用,用来 ...

  3. SQL Server中SCAN 和SEEK的区别

    SQL Server中SCAN 和SEEK的区别 SQL SERVER使用扫描(scan)和查找(seek)这两种算法从数据表和索引中读取数据.这两种算法构成了查询的基础,几乎无处不在.Scan会扫描 ...

  4. iOS UI基础-6.0 UIActionSheet的使用

    UIActionSheet是在iOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件. 使用 1.需要实现UIActionSheetDelegate  协议 @interface NJWisdom ...

  5. Air Jordan 1 Los Primeros Will be unveiled

    This new pair of Air Jordan 1 Los Primeros is part of the popular Air-Jordan- Line signature and is ...

  6. linux文件系统软链接硬链接

    引子 目前,UNIX的文件系统有很多种实现,例如UFS(基于BSD的UNIX文件系统).ext3.ext4.ZFS和Reiserfs等等. 不论哪一种文件系统,总是需要存储数据.硬盘的最小存储单位是扇 ...

  7. chkconfig添加进入服务后,出现的现象

    比如在php-fpm添加服务中,一部分脚步如下 #!/bin/sh       #       # php-fpm - this script starts and stops the php-fpm ...

  8. yii2之增加省市字段

    第一步,利用数据库迁移文件改表 修改一下迁移文件: https://bitbucket.org/ysxy/zijiu.git

  9. select,radio,checkbox兼容性

  10. python requests 请求的封装

    #encoding=utf-8import requestsimport jsonclass HttpClient(object):    def __init__(self):        pas ...