bzoj1022 [SHOI2008]小约翰的游戏(博弈论,Anti-SG)

Anti−SGAnti−SG游戏定义:
决策集合为空的操作者胜。
其余规则与SGSG游戏一致。

SJ定理:
对于任意一个Anti−SG游戏,如果定义所有子游戏的SG值为0时游戏结束,先手必胜的条件:

游戏的SG值为0且所有子游戏SG值均不超过1。
游戏的SG值不为0且至少一个子游戏SG值超过1。
本题容易看出SG(x)=x

大概证明;portal

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define N 60
inline char gc(){
    static char buf[1<<16],*S,*T;
    if(S==T){T=(S=buf)+fread(buf,1,1<<16,stdin);if(T==S) return EOF;}
    return *S++;
}
inline int read(){
    int x=0,f=1;char ch=gc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=gc();
    return x*f;
}
int main(){
//  freopen("a.in","r",stdin);
    int tst=read();
    while(tst--){
        int n=read(),sg=0,flag=0;
        while(n--){int x=read();sg^=x;if(x!=1) flag=1;}
        if((!sg&&!flag)||(sg&&flag)){puts("John");continue;}
        puts("Brother");
    }return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值