zoukankan      html  css  js  c++  java
  • P2575 高手过招

    P2575 高手过招
    把每一行看成一个阶梯nim,每一个空格或者连续的一块算一个阶梯,这个划分模拟一下就会发现确实满足阶梯nim的条件

    #include <iostream>
    #include <cstdio>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #include <cstring>
    #define inf 2147483647
    #define N 1000010
    #define p(a) putchar(a)
    #define For(i,a,b) for(int i=a;i<=b;++i)
    
    using namespace std;
    int T;
    int n,m,ans1,ans2,tot,cnt,x;
    bool vis[30];
    void in(int &x){
        int y=1;char c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
        while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
        x*=y;
    }
    void o(int x){
        if(x<0){p('-');x=-x;}
        if(x>9)o(x/10);
        p(x%10+'0');
    }
    
    signed main(){
        in(T);
        while(T--){
            in(n);      
            ans1=0;
            For(i,1,n){
                in(m);
                ans2=0;tot=0;cnt=20-m+1;
                memset(vis,0,sizeof(vis));
                For(i,1,m){
                    in(x);
                    vis[x]=1;
                }
                For(i,1,20){
                    if(!vis[i]){
                        if((--cnt)&1)
                            ans2^=tot;             
                        tot=0;  
                    }
                    else
                        tot++;
                }
                ans1^=ans2;
            }
            if(ans1)
                puts("YES");
            else
                puts("NO");
        }
        return 0;
    }
  • 相关阅读:
    分清函数指针和指针函数_
    常量指针与指针常量的区别
    Oracle11g数据库在Win系统下的安装
    MySQL-python模块
    堡垒机(paramiko)
    paramiko模块
    线程池
    线程、进程和协程
    Twisted
    SocketServer模块
  • 原文地址:https://www.cnblogs.com/war1111/p/11333935.html
Copyright © 2011-2022 走看看