QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#113159 | #4446. Link is as bear | Tobo# | AC ✓ | 245ms | 3448kb | C++20 | 823b | 2023-06-16 15:56:35 | 2023-06-16 15:56:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define mod 1'000'000'007
void solve()
{
int n;
cin >> n;
vector<i64> s(64);
while (n--)
{
i64 x;
cin >> x;
for (int j = 63; j >= 0; j--)
{
if (x >> j & 1)
{
if (s[j])
x ^= s[j];
else
{
s[j] = x;
x = 0;
}
}
}
}
i64 ans = 0;
for (int i = 63; i >= 0; i--)
if ((ans ^ s[i]) > ans)
ans ^= s[i];
cout << ans << '\n';
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 245ms
memory: 3448kb
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