Gym101128G:Game of Cards
题意:
有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的更多相关文章
- BZOJ 1004 【HNOI2008】 Cards
题目链接:Cards 听说这道题是染色问题的入门题,于是就去学了一下\(Bunside\)引理和\(P\acute{o}lya\)定理(其实还是没有懂),回来写这道题. 由于题目中保证"任意 ...
- 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 ...
- bzoj 1004 Cards
1004: [HNOI2008]Cards Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有 多少种染色方案,Sun ...
- 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 ...
- CF 204B Little Elephant and Cards
题目链接: 传送门 Little Elephant and Cards time limit per test:2 second memory limit per test:256 megab ...
- HDU 1535 Invitation Cards(最短路 spfa)
题目链接: 传送门 Invitation Cards Time Limit: 5000MS Memory Limit: 32768 K Description In the age of te ...
- 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 ...
- 队列 Soldier and Cards
Soldier and Cards 题目: Description Two bored soldiers are playing card war. Their card deck consists ...
- [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 ...
随机推荐
- Google Chrome 调试JS简单教程[更新]
题外话,刚开始我写这篇内容只是将自己了解的一些知识放上来,不巧的是我分析了我的来访日志,很多朋友都有这个需求,为了大家没有白来,我决定充实下这篇文章.最近更新时间2014-02-14 chrome版本 ...
- Oracle11g的服务
成功安装Oracle 11g数据库后,你会发现自己电脑运行速度会变慢,配置较低的电脑甚至出现非常卡的状况,通过禁止非必须开启的Oracle服务可以提升电脑的运行速度.那么,具体该怎么做呢.按照win7 ...
- BZOJ2384:[CEOI2014]Match
浅谈\(KMP\):https://www.cnblogs.com/AKMer/p/10438148.html 题目传送门:https://lydsy.com/JudgeOnline/problem. ...
- SharePoint2013 Online中InfoPath 无法调用WebService
传说微软office365中国区服务器已经迁移到国内,试了下速度果然比之前快了很多,不过随后测试了个简单的功能,还是直接被打击了. 准备在online版本中做一个简单的报销流程测试测试,于是先用Inf ...
- Markdown初步使用
一.兼容 HTML Markdown 的理念是,能让文档更容易读.写和随意改.HTML 是一种发布的格式,Markdown 是一种书写的格式.就这样,Markdown 的格式语法只涵盖纯文本可以涵盖的 ...
- table tr列 鼠标经过时更改背景颜色
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- ES6中的新特性
本人最近学习es6一些方法,难免有些手痒,想着能不能将这些方法总结下,如下 1.数组的扩展 1)首先什么是伪数组 无法直接调用数组方法或期望length属性有什么特殊的行为,但仍可以对真正数组遍历方法 ...
- 【UVA】10391 Compound Words(STL map)
题目 题目 分析 自认已经很简洁了,虽说牺牲了一些效率 代码 #include <bits/stdc++.h> using namespace std; set <s ...
- 上传图片demo
页面: js: 后台: @RequiresPermissions("pointwall:upload:edit") @RequestMapping(value = "sa ...
- Julia - 算术基本函数
符号函数和绝对值函数 abs(x) 函数求 x 的绝对值(幅值) julia> abs(3) 3 julia> abs(-3) 3 abs2(x) 函数求 x 的绝对值(幅值)的平方 ju ...