QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340547#4446. Link is as bearTerac#AC ✓172ms6652kbC++142.0kb2024-02-29 10:00:012024-02-29 10:00:01

Judging History

This is the latest submission verdict.

  • [2024-02-29 10:00:01]
  • Judged
  • Verdict: AC
  • Time: 172ms
  • Memory: 6652kb
  • [2024-02-29 10:00:01]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
namespace IO {
	#if ONLINE_JUDGE
	#define getc() (IS == IT && (IT = (IS = ibuf) + fread(ibuf, 1, IL, stdin), IS == IT) ? EOF : *IS++)
	#else
	#define getc() getchar()
	#endif
	const int IL = 1 << 21, OL = 1 << 21;
	int olen = 0;
	char ibuf[IL], *IS = ibuf, *IT = ibuf, obuf[OL];
	inline int read() {
		register char ch = getc(); register int x = 0, f = 1;
		while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getc(); }
		while(isdigit(ch)) x = x * 10 + ch - 48, ch = getc();
		return x * f;
	}
	inline double readdb() {
		register char ch = getc(); register double x = 0, f = 1;
		while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getc(); }
		while(isdigit(ch)) x = x * 10 + ch - 48, ch = getc();
		if(ch == '.') {
			register double b = 0.1;
			ch = getc();
			while(isdigit(ch)) x += (ch - 48) * b, b *= 0.1, ch = getc();
		}
		return x * f;
	}
	inline int readstr(char *s) {
		register char ch = getc(); register int len = 0;
		while(!isalpha(ch)) ch = getc();
		while(isalpha(ch)) s[++len] = ch, ch = getc();
		return len;
	}
	inline void flush() { fwrite(obuf, 1, olen, stdout); olen = 0; }
	inline void putc(register char ch) { obuf[olen++] = ch; }
	template<class T>
	inline void write(register T x) {
		if(x < 0) obuf[olen++] = '-', x = -x;
		if(x > 9) write(x / 10);
		obuf[olen++] = x % 10 + 48;
	}
} using namespace IO;
const int N = 1e6 + 10;
int T, n, a[N], bas[55];
void insert(int x) {
	for(int i = 52; ~i; i--)
		if(!(x >> i & 1)) continue;
		else {
			if(bas[i]) x ^= bas[i];
			else {
				bas[i] = x;
				break;
			} 
		}
}
int qry() {
	int res = 0;
	for(int i = 52; ~i; i--)
		if(bas[i]) res = max(res, res ^ bas[i]);
	return res;
}
void MAIN() {
	n = read();
	memset(bas, 0, sizeof(bas));
	for(int i = 1; i <= n; i++)
		a[i] = read(), insert(a[i]);
	printf("%lld\n", qry());
}
signed main() {
	T = read();
	while(T--) MAIN();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 172ms
memory: 6652kb

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