山东省赛-博弈-Game



 非常明显的一道博弈题目,可是在求SG的时候,子状态写错了,一直都没有AC。最后还是水过去的额。比赛后还是自己写了一遍;

# include <cstdio>
# include <cstring>
# include <iostream>
using namespace std;

int sg[1200];

int get(int x)
{
    if(x < 0)   return 0;
    if(sg[x] != -1) return sg[x];

    int mex[1200] = {0};
    for(int i = 0;i < x;i++){
        int t = get(i)^get(x-i - 1)^get(i-1)^get(x - i -2);
        mex[t] = 1;
    }
    for(int i = 0;;i++) if(!mex[i]) return sg[x] = i;
}

int main()
{
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","r",stdin);
    int t;
    memset(sg,-1,sizeof(sg));
    scanf("%d",&t);
    while(t--){
        int n;
        scanf("%d",&n);
        if(n <= 2){
            printf("zbybr\n");
            continue;
        }
        if(get(n - 1) || get(n - 2))    printf("blankcqk\n");
        else    printf("zbybr\n");
    }
    return 0;
}


posted @ 2017-08-09 08:39  yxysuanfa  阅读(142)  评论(0编辑  收藏  举报