题意:

有P摞纸牌和一个数字k,每次可以从一摞中拿0-k张牌,拿完再剩下的牌中的第一张数字是几,就必须再拿几张,谁不能拿谁输。

emmm感觉好像就是裸的SG游戏啊,数据不大,递推出每一摞牌的SG值,然后不同摞之间直接异或一下,如果最后结果是0那么先手必输否则先手必胜。

刚好那几天一直在学SG,所以在场上很容易A掉了,得瑟了好久~

 #include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream> using namespace std;
const int maxn=+;
int p,k;
int a[maxn];
int SG[maxn],vis[maxn];
void get_SG(int n){
memset(SG,,sizeof(SG));
for(int i=;i<=n;i++){
memset(vis,,sizeof(vis));
for(int j=;j<=min(i,k);j++){
if(j==i)continue;
int tmp=i-j-a[i-j];
if(tmp>=)
vis[SG[tmp]]=;
}
for(int j=;;j++){
if(!vis[j]){
SG[i]=j;
break;
}
}
}
return ;
}
int main(){
scanf("%d%d",&p,&k);
int ans=;
for(int i=;i<=p;i++){
scanf("%d",&a[]);
for(int j=;j<=a[];j++)
scanf("%d",&a[j]);
get_SG(a[]);
ans^=SG[a[]];
}
if(ans)
printf("Alice can win.");
else
printf("Bob will win."); return ;
}

Gym101128G:Game of Cards的更多相关文章

  1. BZOJ 1004 【HNOI2008】 Cards

    题目链接:Cards 听说这道题是染色问题的入门题,于是就去学了一下\(Bunside\)引理和\(P\acute{o}lya\)定理(其实还是没有懂),回来写这道题. 由于题目中保证"任意 ...

  2. Codeforces Round #384 (Div. 2) 734E Vladik and cards

    E. Vladik and cards time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. bzoj 1004 Cards

    1004: [HNOI2008]Cards Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有 多少种染色方案,Sun ...

  4. codeforces 744C Hongcow Buys a Deck of Cards

    C. Hongcow Buys a Deck of Cards time limit per test 2 seconds memory limit per test 256 megabytes in ...

  5. CF 204B Little Elephant and Cards

    题目链接: 传送门 Little Elephant and Cards time limit per test:2 second     memory limit per test:256 megab ...

  6. HDU 1535 Invitation Cards(最短路 spfa)

    题目链接: 传送门 Invitation Cards Time Limit: 5000MS     Memory Limit: 32768 K Description In the age of te ...

  7. Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组

    E. George and Cards   George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...

  8. 队列 Soldier and Cards

    Soldier and Cards 题目: Description Two bored soldiers are playing card war. Their card deck consists ...

  9. [CareerCup] 18.2 Shuffle Cards 洗牌

    18.2 Write a method to shuffle a deck of cards. It must be a perfect shuffle—in other words, each of ...

随机推荐

  1. 【转】简明 Python 教程

    原文网址:http://woodpecker.org.cn/abyteofpython_cn/chinese/ 简明 Python 教程Swaroop, C. H. 著沈洁元  译www.byteof ...

  2. angular-ui-bootstrap弹出框的使用(一)

    在开发项目时,我们经常性的会遇到弹出框的需求,例如登陆,注册,添加信息等等....面对这一需求,我们当然也可以使用自己的双手进行编写,如果你时间充足可以试试. 今天我们讲解一下如何在angular框架 ...

  3. 如何在项目中使用requireJS

    本文主要讲讲如何在一个项目中合理的使用requireJS,来加载js代码,这里是个实际例子,讲解不多, 看详情请连接到:http://www.cnblogs.com/evaling/p/6722760 ...

  4. U盘永久系统-centos

    U盘永久系统-centos 问题: 服务器centos系统崩溃,重装需要备份其中数据,约4T,实验室有远程存储服务器,然而rescue模式进去后无法挂载远程存储,只好做一个真正的U盘系统解决了. 方案 ...

  5. RK3288 修改浏览器默认主页和书签

    path:packages/apps/Browser/res/values/strings.xml 修改浏览器默认主页: <!-- The default homepage. --> &l ...

  6. Ubuntu : 在主机和虚拟机之间传文件

    电脑用的是windows的系统,vmware player打开了一台ubuntu虚拟机,想在它们之间传送文件. 在宿主机上安装FTP文件传输软件 步骤如下: 1.Ubuntu中安装ssh,命令:sud ...

  7. MOSS 2013研究系列---修改默认Logo

    开发SharePoint2013 的时候,系统里面有一个“SharePoint” 的logo,客户很少不满意,我们的系统不能出现产品的名称,如下图: 咋么修改呢,咨询了广大网友,给出了一个解决方案: ...

  8. (转)将rdlc报表作为资源嵌套使用

    本文转载自:http://www.cnblogs.com/chenxizhang/archive/2009/05/16/1458469.html 如果我们准备在Windows Forms里面使用rdl ...

  9. HBase之五:hbase的region分区

    一.Region 概念 Region是表获取和分布的基本元素,由每个列族的一个Store组成.对象层级图如下: Table (HBase table) Region (Regions for the ...

  10. python3第一次作业

    需要一个文件users,里面有用户名密码以及是否锁定的标识符 lzd--123--1wdl--123--0lw--123--0aaa--123--0bbb--123--0ccc--123--1ddd- ...