题意:

有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. 如何在CentOS系统中安装配置SNMP服务

    CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是Linux发行版之一,现在有一大部分服务器在使用此操作系统:SNMP(简单网络 ...

  2. 中兴G718C开发者模式开启

    系统设置--关于手机--版本号,连按七次,打开开发者选项 请进入设置——连接到PC——默认连接类型——安装驱动,选择即可.然后将手机和电脑连接,打开“我的电脑”或“计算机”会弹出可移动盘符“USB D ...

  3. Qt学习之秒表的实现(StopWatch) (转)

    秒表对于我来说并不陌生,在之前自己学习单片机时,实现过秒表和数字钟:基本思路:开启单片机带的定时器,并设置它没10ms溢出一次,分别用三个变量hour,minute,secong记录秒表的时分秒,然后 ...

  4. Web 漏洞分析与防御之点击劫持(三)

    原文地址:Web 漏洞分析与防御之点击劫持(三) 博客地址:http://www.extlight.com 一.全称 点击劫持,顾名思义,用户点击某个按钮,却触发了不是用户真正意愿的事件. 二.原理 ...

  5. 安装 LAMP

    卸载 并安装 MYSQL rpm -qa | grep mysql rpm -e mysql-libs--.el6.x86_64 -.el6.x86_64 cd /usr/local/src/ wge ...

  6. Android 从上层到底层-----app层

    CPU:RK3288 系统:Android 5.1 功能:上层 app 控制 led 亮灭 开发板:Firefly RK3288 MainActivity.java package com.aaron ...

  7. 使用Octave分析GNU Radio的数据

    Octave 是 GNU Radio 的最流行的分析工具,因此 GNU Radio 软件包也包含它自身的一组脚本用于读取和语法分析输出.本文介绍如何使用 Octave 分析 GNU Radio 产生的 ...

  8. 老齐python-基础6(循环 if while for)

    1.条件语句if 依据某个条件,满足这个条件后执行下面的内容 >>> if bool(conj): #语法 do something >>> a = 8 >& ...

  9. 让html标签显示在页面上

    用 <xmp></xmp> 标签包起来,里面的所有文字会原样显示出来 <xmp><b>1</b><div>2</div&g ...

  10. Condition分析

    Condition中提供了一组类似于Object中的监视器方法.与Lock配合可以完成等待通知模式. Condition只能通过Lock#newCondition()方法获取,所以Condition是 ...