QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#704 | #456139 | #8823. Game: Battle of Menjis | yemuzhe | yemuzhe | Success! | 2024-06-27 11:29:04 | 2024-06-27 11:29:06 |
详细
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 | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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
*/