zoukankan      html  css  js  c++  java
  • BZOJ 1299 [LLH邀请赛]巧克力棒

    如果没有拿巧克力棒的操作的话 是一个裸的NIM游戏 

    现在加入了这个操作 改变了异或的值

    那么我们只需要判断先手的人是否可以从集合中取出一个极大的异或值为0的子集即可

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    #define ll long long
    #define MAX 15
    inline int read()
    {
        int x=0;bool t=false;char ch=getchar();
        while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
        if(ch=='-')t=true,ch=getchar();
        while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
        return t?-x:x;
    }
    struct xxj
    {
        int p[31];
        bool insert(int x)
            {
                for(int i=30;~i;--i)
                    if(x&(1<<i))
                    {
                        if(!p[i]){p[i]=x;return true;}
                        x^=p[i];
                    }
                return false;
            }
        void clear(){memset(p,0,sizeof(p));}
    }G;
    int n,a[MAX];
    int main()
    {
        int T=10;
        while(T--)
        {
            n=read();
            for(int i=1;i<=n;++i)a[i]=read();
            G.clear();bool fl=false;
            for(int i=1;i<=n;++i)
                if(!G.insert(a[i]))fl=true;
            puts(fl?"NO":"YES");
        }
        return 0;
    }
  • 相关阅读:
    CCF201604试题
    CCF201512试题
    CCF201509试题
    CCF201509试题
    CCF201503试题
    CCF201503试题
    CCF201412试题
    CCF201412试题
    CCF201409试题
    CCF201409试题
  • 原文地址:https://www.cnblogs.com/Aragaki/p/11491957.html
Copyright © 2011-2022 走看看