萌新求助:WA 30 pts 。。。
查看原帖
萌新求助:WA 30 pts 。。。
438461
liu_chen_hao楼主2023/8/3 20:38
#include <bits/stdc++.h>
using namespace std;
const int N=1005;

int aqx,n,m,a[N][35],b[N][35],cnt[N],sg[N],SG;

int read() {
    int sss=0,www=1;
    char ccch=getchar();
    while(ccch<'0' || ccch>'9') { if(ccch=='-') www=-1; ccch=getchar(); }
    while(ccch>='0' && ccch<='9') sss=sss*10+ccch-'0',ccch=getchar();
    return sss*www;
}
int main()
{
    aqx=read();
    while(aqx--)
    {
    	memset(b,0,sizeof(b));
    	memset(a,0,sizeof(a));
    	memset(cnt,0,sizeof(cnt));
    	memset(sg,0,sizeof(sg));
    	SG=0;

    	n=read();
    	for(int i=1; i<=n; i++)
    	{
    		m=read();
    		for(int j=1,x; j<=m; j++)
    		{
    			x=read();
    			b[i][x]=1;
    		}
    	}
    	for(int i=1; i<=n; i++)
    	{
    		for(int j=20; j>=1; j--)
    		{
    			if(b[i][j])
    			{
    				int k=j;
    				while(k-1>=1 && b[i][k-1]) --k;
    				a[i][cnt[i]]=j-k+1;
    				++cnt[i];
    				j=k;
    			}
    			else
    			{
    				a[i][cnt[i]]=0;
    				++cnt[i];
    			}
    		}
    	}

    	for(int i=1; i<=n; i++)
    		for(int j=1; j<=cnt[i]; j+=2) sg[i]^=a[i][j];
    	for(int i=1; i<=n; i++) SG^=sg[i];
    	if(SG) printf("YES\n");
    	else printf("NO\n");
    }
    
    return 0;
}
2023/8/3 20:38
加载中...