题意:

有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. 顺丰品牌研究http://www.kiees.cn/sf/express/brand.htm

    顺丰控股股份有限公司,顺丰速运SF,始于1993年,国内速递行业中民族品牌的佼佼者,以其速度快/安全性能高蜚声业界,现已开通海外快递服务,2017年2月完成借壳上市 1993年,顺丰诞生于广东顺德.自 ...

  2. phoenix 使用activerecord模式框架ecto 访问数据库

    备注:    需要先安装mysql 以及phoenix 框架,测试使用的是docker 进行安装,具可以参考代码    1. 创建项目 mix phx.new first --database mys ...

  3. vi配置

    1.配置文件的位置在目录 /etc/ 下面,有个名为vimrc的文件,这是系统中公共的vim配置文件,对所有用户都有效.而在每个用户的主目录下,都可以自己建立私有的配置文件,命名为:“.vimrc”. ...

  4. POJ2503:Babelfish

    浅谈\(Trie\):https://www.cnblogs.com/AKMer/p/10444829.html 题目传送门:http://poj.org/problem?id=2503 \(Trie ...

  5. Java连接MySQL数据库和Oracle数据库并进行简单的SQL操作的一次尝试

    MySQL和Oracle的JDBC的maven dependency如下: <!-- mysql --> <dependency> <groupId>mysql&l ...

  6. python接口自动化22-签名(signature)鉴权(authentication)之加密(HEX、MD5、HMAC-SHA256)

    前言 开放的接口为了避免被别人乱调用,浪费服务器资源,这就涉及到签名(Signature)加密了 API 使用签名方法(Signature)对接口进行鉴权(Authentication).每一次请求都 ...

  7. java代码----大二上机考试

    总结:对 冒泡排序熟悉,但不能灵活插入代码 package com.dkl; import java.io.*; import java.io.IOException; import java.uti ...

  8. Android软键盘弹出将底部栏顶上去并不会挤压界面

    界面需要,找到了一种不需要去设置android:windowSoftInputMode属性的解决keyboard和layout不适问题 有关设置android:windowSoftInputMode的 ...

  9. 超详细的php用户注册页面填写信息完整实例(附源码)

    这篇文章主要介绍了一个超详细的php用户注册页面填写信息完整实例,内容包括邮箱自动匹配.密码强度验证以及防止表单重复等,小编特别喜欢这篇文章,推荐给大家. 注册页面是大多数网站必备的页面,所以很有必要 ...

  10. Docker - 使用Swarm和compose部署服务(containers)

    前言 在之前使用Docker的过程中,一直是用 Docker run 命令单独启动container后再加入Overlay网络的方式实现部署工作的. 这种方式看似直接,但是随着服务所包含的contai ...