原文讲解很nice,我尝试换种观点

设背面朝上为F,否则T,

那么局面FFFFFF肯定为0

局面FTFFFF可以转为上面局面0,设为1

局面FFTFFF可以转到0,1,设为2

子游戏SG(x)=x

对于游戏和TTFTFFTF

我们可以分解为局面1,2,4,7的子游戏

然后SG求和就好,所以形式上和nim无异

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#define rep(i,j,k) for(register int i=j;i<=k;i++)
#define rrep(i,j,k) for(register int i=j;i>=k;i--)
#define erep(i,u) for(register int i=head[u];~i;i=nxt[i])
#define iin(a) scanf("%d",&a)
#define lin(a) scanf("%lld",&a)
#define din(a) scanf("%lf",&a)
#define s0(a) scanf("%s",a)
#define s1(a) scanf("%s",a+1)
#define print(a) printf("%lld",(ll)a)
#define enter putchar('\n')
#define blank putchar(' ')
#define println(a) printf("%lld\n",(ll)a)
#define IOS ios::sync_with_stdio(0)
using namespace std;
const int maxn = 1e6+11;
const int oo = 0x3f3f3f3f;
const double eps = 1e-7;
typedef long long ll;
ll read(){
ll x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,r,c;
char str[maxn];
int main(){
while(cin>>n){
s1(str);
ll t=0;
rep(i,1,n){
if(str[i]=='H')t^=i;
}
if(t) cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
}
return 0;
}

HihoCoder - 1172 SG函数应用的更多相关文章

  1. HDU 5795 A Simple Nim 打表求SG函数的规律

    A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player wh ...

  2. 【转】博弈—SG函数

    转自:http://chensmiles.blog.163.com/blog/static/12146399120104644141326/ http://blog.csdn.net/xiaofeng ...

  3. HDU 1848 Fibonacci again and again【SG函数】

    对于Nim博弈,任何奇异局势(a,b,c)都有a^b^c=0. 延伸: 任何奇异局势(a1, a2,… an)都满足 a1^a2^…^an=0 首先定义mex(minimal excludant)运算 ...

  4. POJ2425 A Chess Game[博弈论 SG函数]

    A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3917   Accepted: 1596 Desc ...

  5. bzoj1188 [HNOI2007]分裂游戏 博弈论 sg函数的应用

    1188: [HNOI2007]分裂游戏 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 973  Solved: 599[Submit][Status ...

  6. BZOJ1188 [HNOI2007]分裂游戏(SG函数)

    传送门 拿到这道题就知道是典型的博弈论,但是却不知道怎么设计它的SG函数.看了解析一类组合游戏这篇论文之后才知道这道题应该怎么做. 这道题需要奇特的模型转换.即把每一个石子当做一堆石子,且原来在第i堆 ...

  7. sg函数与博弈论2

    参考链接: http://blog.sina.com.cn/s/blog_51cea4040100h3l9.html 这篇主要就是讲anti-sg.multi-sg和every-sg的. 例1 poj ...

  8. sg函数与博弈论

    这个标题是不是看起来很厉害呢... 我们首先来看一个最简单的游戏.比如我现在有一堆石子,有p个,每次可以取走若干个(不能不取),不能取的人就输了. 现在假设有两个人要玩这个游戏,一个人先手,一个人后手 ...

  9. hdu1536&&hdu3023 SG函数模板及其运用

    S-Nim Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status ...

随机推荐

  1. ubuntu 64 14.04 共享文件夹问题

    转自http://blog.csdn.net/gongyuan073/article/details/46604233 原文链接: http://blog.csdn.NET/chinley/artic ...

  2. 1.介绍templates

    我们现在要计算int和double类型数据的平方,我们就需要2个函数: #include <iostream> using namespace std; int square(int x) ...

  3. 编写高质量代码改善C#程序的157个建议——建议42:使用泛型参数兼容泛型接口的不可变性

    建议42:使用泛型参数兼容泛型接口的不可变性 让返回值类型返回比声明的类型派生程度更大的类型,就是“协变”.如: public Employee GetAEmployee(string name) { ...

  4. iOS应用审核时间注意点

    1.重大节假日不审核 美国重大节假日期间不审核,具体审核时间查看官方通知

  5. 第二篇 Python运算符

    1.算术运算符 运算符 描述  +  两个值相加  -  两个值相减  *  两个值相乘  /  两个值相除  %  得到两个数相除的余数  **  x**y得到x的y次幂  //  返回两个数相除商 ...

  6. python—Celery异步分布式

    python—Celery异步分布式 Celery  是一个python开发的异步分布式任务调度模块,是一个消息传输的中间件,可以理解为一个邮箱,每当应用程序调用celery的异步任务时,会向brok ...

  7. 【bzoj3998】弦论 后缀自动机

    Description 对于一个给定长度为N的字符串,求它的第K小子串是什么. Input 第一行是一个仅由小写英文字母构成的字符串S 第二行为两个整数T和K,T为0则表示不同位置的相同子串算作一个. ...

  8. gluster peer probe: failed: Probe returned with unknown errno 107解决方法

    当在glusterfs中将服务器加到存储池中,及运行”gluster peer probe server”命令, 遇到peer probe: failed: Probe returned with u ...

  9. Shell等,不等......

    -eq           //等于 -ne           //不等于 -gt            //大于 (greater ) -lt            //小于  (less) -g ...

  10. cenos安装memcache

    注意事项: 1 安装时注意权限问题 sudo 2 需先启动memcache服务 php才能测试   Memcached是高性能的,分布式的内存对象缓存系统,用于在动态应用中减少数据库负载,提升访问速度 ...