题意:

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

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

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

  1. #include <cstdio>
  2. #include <algorithm>
  3. #include <cstring>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7. const int maxn=+;
  8. int p,k;
  9. int a[maxn];
  10. int SG[maxn],vis[maxn];
  11. void get_SG(int n){
  12. memset(SG,,sizeof(SG));
  13. for(int i=;i<=n;i++){
  14. memset(vis,,sizeof(vis));
  15. for(int j=;j<=min(i,k);j++){
  16. if(j==i)continue;
  17. int tmp=i-j-a[i-j];
  18. if(tmp>=)
  19. vis[SG[tmp]]=;
  20. }
  21. for(int j=;;j++){
  22. if(!vis[j]){
  23. SG[i]=j;
  24. break;
  25. }
  26. }
  27. }
  28. return ;
  29. }
  30. int main(){
  31. scanf("%d%d",&p,&k);
  32. int ans=;
  33. for(int i=;i<=p;i++){
  34. scanf("%d",&a[]);
  35. for(int j=;j<=a[];j++)
  36. scanf("%d",&a[j]);
  37. get_SG(a[]);
  38. ans^=SG[a[]];
  39. }
  40. if(ans)
  41. printf("Alice can win.");
  42. else
  43. printf("Bob will win.");
  44.  
  45. return ;
  46. }

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. Google Chrome 调试JS简单教程[更新]

    题外话,刚开始我写这篇内容只是将自己了解的一些知识放上来,不巧的是我分析了我的来访日志,很多朋友都有这个需求,为了大家没有白来,我决定充实下这篇文章.最近更新时间2014-02-14 chrome版本 ...

  2. Oracle11g的服务

    成功安装Oracle 11g数据库后,你会发现自己电脑运行速度会变慢,配置较低的电脑甚至出现非常卡的状况,通过禁止非必须开启的Oracle服务可以提升电脑的运行速度.那么,具体该怎么做呢.按照win7 ...

  3. BZOJ2384:[CEOI2014]Match

    浅谈\(KMP\):https://www.cnblogs.com/AKMer/p/10438148.html 题目传送门:https://lydsy.com/JudgeOnline/problem. ...

  4. SharePoint2013 Online中InfoPath 无法调用WebService

    传说微软office365中国区服务器已经迁移到国内,试了下速度果然比之前快了很多,不过随后测试了个简单的功能,还是直接被打击了. 准备在online版本中做一个简单的报销流程测试测试,于是先用Inf ...

  5. Markdown初步使用

    一.兼容 HTML Markdown 的理念是,能让文档更容易读.写和随意改.HTML 是一种发布的格式,Markdown 是一种书写的格式.就这样,Markdown 的格式语法只涵盖纯文本可以涵盖的 ...

  6. table tr列 鼠标经过时更改背景颜色

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  7. ES6中的新特性

    本人最近学习es6一些方法,难免有些手痒,想着能不能将这些方法总结下,如下 1.数组的扩展 1)首先什么是伪数组 无法直接调用数组方法或期望length属性有什么特殊的行为,但仍可以对真正数组遍历方法 ...

  8. 【UVA】10391 Compound Words(STL map)

    题目 题目     分析 自认已经很简洁了,虽说牺牲了一些效率     代码 #include <bits/stdc++.h> using namespace std; set <s ...

  9. 上传图片demo

    页面: js: 后台: @RequiresPermissions("pointwall:upload:edit") @RequestMapping(value = "sa ...

  10. Julia - 算术基本函数

    符号函数和绝对值函数 abs(x) 函数求 x 的绝对值(幅值) julia> abs(3) 3 julia> abs(-3) 3 abs2(x) 函数求 x 的绝对值(幅值)的平方 ju ...