QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#743925 | #4446. Link is as bear | s1amese | AC ✓ | 530ms | 3604kb | C++20 | 545b | 2024-11-13 20:19:34 | 2024-11-13 20:19:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
i64 a[60];
void add(i64 x) {
for (int i = 50; i >= 0; i--)
if (x >> i & 1) {
if (a[i])
x ^= a[i];
else {
a[i] = x;
break;
}
}
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
fill(a, a + 60, 0);
for (int i = 0; i < n; i++) {
i64 x;
cin >> x;
add(x);
}
i64 ans = 0;
for (int i = 50; i >= 0; i--)
if (!(ans >> i & 1))
ans ^= a[i];
cout << ans << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 530ms
memory: 3604kb
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