题意:

给一个矩阵,每一次一个玩家可以从任意一行中选任意数量的格子并从中拿石头(但最后总数要大于等于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. 帝国cms底部代码哪里改?要修改版权和统计代码

    最近接手的几个站是用帝国cms做的,底部代码那边都有一个**设计的链接,还有一些不相关的东西,第一眼看到就想把那些帝国cms底部代码清理掉,这就是让别人建站的烦恼,让他们删除说要收费,坑就一个字,自己 ...

  2. word 加载adobe acrobat ,保存word中的清晰图片

    1:先安装 adobe 并激活 https://blog.csdn.net/xintingandzhouyang/article/details/82558235 2:打开word,点击   文件&g ...

  3. myeclipse连接并运行sql文件

    1:在工程目录上右键>new >SQL File  ,写入sql 2:在sql文件上面右键>execute sql files 3:选择数据库类型,并点击create创建一个连接: ...

  4. mybatis中使用where in查询时的注意事项

    我使用的时候collection值为mapper的参数名如:int deleteRoleByUserIds(@Param("userIds") String[] userIds); ...

  5. hdu1505City Game(扫描线)

    http://acm.hdu.edu.cn/showproblem.php?pid=1505 题意:R为被占位置,F为空位,求出最大子空矩阵大小*3. 思路:1.悬线法,记录每个位置的悬线能到达的左边 ...

  6. Ng线性回归实现学习[转载]

    转自:https://github.com/huanting74/Coursera-ML-AndrewNg 1.可视化数据 import pandas as pd import seaborn as ...

  7. PAT 1034 Head of a Gang[难][dfs]

    1034 Head of a Gang (30)(30 分) One way that the police finds the head of a gang is to check people's ...

  8. RAC禁用DRM特性

    查看"_gc"开头的隐藏参数值: set linesize 333 col name for a35 col description for a66 col value for a ...

  9. AnsiString和各种数据类型间相互转换 [数据转换]

    //Ansistring 转 char void __fastcall TForm1::Button1Click(TObject *Sender) { AnsiString Test = " ...

  10. css 播放器按钮实现

    效果图 html代码 //播放按钮 <div id="playBtn" class="circle" style="margin: 20px 0 ...