首页 > 其他 > 详细

P2575 高手过招

时间:2019-08-11 11:22:23      阅读:60      评论:0      收藏:0      [点我收藏+]

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;
}

 

P2575 高手过招

原文:https://www.cnblogs.com/war1111/p/11333935.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!