QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#704 | #456139 | #8823. Game: Battle of Menjis | yemuzhe | yemuzhe | Success! | 2024-06-27 11:29:04 | 2024-06-27 11:29:06 |
Details
Extra Test:
Wrong Answer
time: 0ms
memory: 1540kb
input:
1 2 1 1000000000 1
output:
1000000000
result:
wrong answer 1st numbers differ - expected: '1000000001', found: '1000000000'
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#456139 | #8823. Game: Battle of Menjis | yemuzhe | WA | 47ms | 2024kb | C++14 | 840b | 2024-06-27 11:27:49 | 2024-06-27 11:29:47 |
answer
#include <cstdio>
#include <algorithm>
#define N 100005
#define LGA 35
#define ctz __builtin_ctz
using namespace std;
const int lga = 29;
int T, n, s, ans, a[N], cnt[LGA];
int main ()
{
scanf ("%d", &T);
while (T --)
{
scanf ("%d%*d", &n), s = ans = 0;
for (int i = 0; i <= lga; i ++) cnt[i] = 0;
for (int i = 1; i <= n; i ++)
{
scanf ("%d", &a[i]), s ^= a[i];
if (a[i]) cnt[ctz (a[i])] ++;
if (a[i] == 1e9) break;
}
for (int i = 1, res; res = s, i <= n; i ++)
{
if (a[i]) cnt[ctz (a[i])] --;
for (int j = 0; j <= lga; j ++) if (cnt[j])
{
int now = s ^ a[i] ^ a[i] + 1;
now ^= 1 << j ^ (1 << j) - 1;
res = min (res, now);
}
ans = max (ans, res);
if (a[i]) cnt[ctz (a[i])] ++;
}
printf ("%d\n", ans);
}
return 0;
}
/*
1
2 1
1 1
*/