QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#60404#4446. Link is as bearqinjianbin#AC ✓350ms2372kbC++17718b2022-11-04 14:13:172022-11-04 14:13:17

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-04 14:13:17]
  • 评测
  • 测评结果:AC
  • 用时:350ms
  • 内存:2372kb
  • [2022-11-04 14:13:17]
  • 提交

answer

#include<cstdio>

typedef long long LL;

const int maxn =1e5+5;
const int log2maxn =60;

int n;
LL p[maxn];
LL a[maxn]; 

void standing_by()
{
	int i,j;
	LL k;
	for(i=0;i<log2maxn;i++)
		p[i]=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if (a[i]==0) continue;
		k=a[i];
		for(j=log2maxn-1;j>=0;j--)
			if ((k>>j)&1)
			{
				if (p[j]==0)
				{
					p[j]=k;
					break;
				}else {
					k^=p[j];
				}
			}
	}
}

void complete()
{
	LL ans=0;
	int i;
	for(i=log2maxn-1;i>=0;i--)
		if (((ans>>i)&1)==0) ans^=p[i];
	
	printf("%lld\n",ans);
}

int main()
{
	int t;
	scanf("%d",&t);
	for(;t;t--)
	{
		standing_by();
		complete();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 350ms
memory: 2372kb

input:

22222
100000
595189703884863 72716684812661 449525802123580 504421888022388 390139608591346 108895143840760 170477720052912 185583843894744 201608404318832 128831549357316 521084715261656 668960191579878 573530403227342 489014525501629 56366633717911 1705111713690 227582321537214 710815946393065 169...

output:

1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
11258999068...

result:

ok 22222 lines