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 ...
随机推荐
- caddy server 几个常用插件
1.log日志 log /var/www/log/example.log 2.目录访问 browse 3.gzip压缩 gzip 4.自主ssl证书 tls /path/ssl/exa ...
- Linux下gdb线程的调试
多线程的调试命令 1.info threads: 这条命令显示的是当前可调试的所有线程,GDB会给每一个线程都分配一个ID.前面有*的线程是当前正在调试的线程. 2.thread ID: 切换到当前调 ...
- oracle表空间维护常用命令
---查看表空间的名字及文件所在位置: select tablespace_name, file_id, file_name,round(bytes/(1024*1024),0) total_spac ...
- 相关TableLayoutPanel分页显示自定义控件
public partial class AcrossGrid : UserControl { /// <summary> /// 一页数量 /// </summary> ; ...
- hadoop深入学习之SequenceFile
的1个byte 3.Key和Value的类名 4.压缩相关的信息 5.其他用户定义的元数据 6.同步标记,sync marker Metadata 在文件创建时就写好了,所以也是不能更改的.条记录存储 ...
- Hadoop序列化与Writable接口(二)
Hadoop序列化与Writable接口(二) 上一篇文章Hadoop序列化与Writable接口(一)介绍了Hadoop序列化,Hadoop Writable接口以及如何定制自己的Writable类 ...
- 编译Lichee(FridenlyARM NanoPi-M1)碰到的问题及解决办法
1. 提示libz.so.1找不到 需要在ubuntu上安装下面两个包: sudo apt-get install lib32ncurses5 ia32-libs 2. 提示xt_hl.o没有make ...
- 登录MySQL非默认3306端口号的语句
这里登陆的是mysql3308端口号的数据库 mysql -P3308 -p用户名 -u密码
- ubuntu 进入单用户模式
进入单用户模式: 按shift进入 1.开机到grub时,用上下键移到第二行的恢复模式,按e(注意不是回车) 即Ubuntu,With Linux 3.2.0-23-generic(recovery ...
- [模拟赛]异或最大值 maxinum
此题在考试时用暴力,暴了30分. 献上30分代码: #include<stdio.h> ]; int main() { int n,t,c,i,max,j,d; freopen(" ...