题意:

有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. springboot: 集成jdbc

    1.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...

  2. Linux 文件名中包含特殊字符

    文件和文件夹的名称中有特殊字符,操作有两种方式( - 在文件名称最前面除外). 例如:文件名为 a&b.c 1.通过转移符 "\" $ touch   a\&b.c ...

  3. 老齐python-基础8(函数)

    1.函数基本概念 2.理解函数 python中一个函数,就是一种映射关系 3.定义函数 #!/usr/bin/env python #coding:utf-8 def add_function(a,b ...

  4. Unit08: 过滤器、监听器

    Unit08: 过滤器.监听器 下面这些小案例主要演示的filter的执行时机: web package web; import java.io.IOException; import javax.s ...

  5. 干净的 js测试页面

    <!DOCTYPE html><html lang="en" > <head> <meta charset="utf-8&quo ...

  6. 谈谈GPU与FPGA的一些看法

    从几个方面来介绍一下GPU和FPGA. 从峰值性能来说,GPU(10Tflops)远远高于FPGA(<1TFlops).GPU上面成千上万个core同时跑在GHz的频率上还是非常壮观的,最新的G ...

  7. java代码------------条件运算符 ?:

    总结: package com.sads; //?: //这个运算符是条件运算符 //条件式?值:值 public class Sd { public static void main(String[ ...

  8. java代码-----运用endWith()和start()方法

    总结: package com.a.b; //startWith().和endWith()是检查一个字符串是否以一个特定的字符序列开始或结束 public class Sdfs { public st ...

  9. ORA-01146: cannot start online backup - file 1 is already in backup ORA-01110: data file 1: 'C:\ORACLE\ORADATA\ORCL8\SYSTEM01.DBF'

    问题: Error: [1146] ORA-01146: cannot start online backup - file 1 is already in backup ORA-01110: dat ...

  10. 《C++ Primer》读书笔记

    在C++中,基类必须指出希望派生类重新定义哪些函数,定义为virtual的函数是基类期待派生类重新定义的,基类希望派生类继承的函数不能定义为虚函数. 引用和指针的静态类型与动态类型可以不同,这是C++ ...