Submission #19038023


Source Code Expand

Copy
#include<bits/stdc++.h>
#define ll long long
#define re register
#define INF 2147483647
#define ull unsigned long long
using namespace std;

inline ull read()
{
	ull f=1,x=0;char s=getchar();
	while(s<'0'||s>'9')
	{
		if(s=='-') f=-1;
		s=getchar();
	}
	while(s>='0'&&s<='9')
	{
		x=x*10+s-48;
		s=getchar();
	}
	return f*x;
}

const int N=1e6+5;
ull a[N];
int vis[105];

int main()
{
	int n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	ull sum=0;
	for(int i=1;i<=n;i++)
	{
		sum^=a[i];
		for(int j=0;j<64;j++)
			if((a[i]>>j)&1)
			{
				vis[j]=1;
				break;
			}
	}
	int ans=0;
	for(int i=63;i>=0;i--)
		if((sum>>i)&1)
		{
			if(!vis[i])
			{
				puts("-1");
				return 0;
			}
			sum^=(((ull)1<<i)-1+((ull)1<<i));
			ans++;
		}
	printf("%d\n",ans);
	return 0;
} 

Submission Info

Submission Time
Task C - Cheating Nim
User luogu_bot2
Language C++ (GCC 9.2.1)
Score 500
Code Size 821 Byte
Status AC
Exec Time 14 ms
Memory 4552 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 26
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 8 ms 3516 KB
001.txt AC 2 ms 3624 KB
002.txt AC 12 ms 4392 KB
003.txt AC 5 ms 4080 KB
004.txt AC 6 ms 3812 KB
005.txt AC 4 ms 3824 KB
006.txt AC 12 ms 4364 KB
007.txt AC 11 ms 4480 KB
008.txt AC 12 ms 4552 KB
009.txt AC 11 ms 4476 KB
010.txt AC 11 ms 4540 KB
011.txt AC 13 ms 4308 KB
012.txt AC 14 ms 4436 KB
013.txt AC 11 ms 4368 KB
014.txt AC 14 ms 4532 KB
015.txt AC 11 ms 4372 KB
016.txt AC 12 ms 4344 KB
017.txt AC 5 ms 4176 KB
018.txt AC 9 ms 4472 KB
019.txt AC 14 ms 4336 KB
020.txt AC 14 ms 4208 KB
021.txt AC 3 ms 3524 KB
022.txt AC 2 ms 3620 KB
023.txt AC 12 ms 4404 KB
example0.txt AC 1 ms 3696 KB
example1.txt AC 2 ms 3600 KB