QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#456128#8823. Game: Battle of MenjisyemuzheWA 34ms1612kbC++14806b2024-06-27 11:18:442024-06-27 11:18:45

Judging History

你现在查看的是最新测评结果

  • [2024-06-27 11:29:18]
  • hack成功,自动添加数据
  • (/hack/704)
  • [2024-06-27 11:18:45]
  • 评测
  • 测评结果:WA
  • 用时:34ms
  • 内存:1612kb
  • [2024-06-27 11:18:44]
  • 提交

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 = 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])] ++;
		}
		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 3
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1612kb

input:

4
2 3
1 1
4 4
0 0 0 0
4 1
1 2 4 8
13 5
1 1 4 5 1 4 1 9 1 9 8 1 0

output:

0
0
9
11

result:

ok 4 number(s): "0 0 9 11"

Test #2:

score: -100
Wrong Answer
time: 34ms
memory: 1584kb

input:

100000
1 5
0
4 5
4 4 3 5
5 2
0 1 7 5 4
4 1
6 4 4 4
1 5
3
2 2
1 1
3 1
5 4 0
2 4
0 3
2 2
1 7
3 1
2 1 6
2 4
5 1
3 1
3 7 0
4 4
7 5 4 4
3 3
1 1 5
1 3
3
3 2
3 7 4
4 1
3 1 0 5
5 3
6 2 3 6 3
3 1
2 6 6
4 4
5 4 1 3
2 1
4 4
4 5
0 1 6 5
4 5
0 7 7 5
2 4
4 0
5 1
7 0 2 6 0
3 4
5 2 3
2 3
4 3
3 2
1 0 1
2 2
6 5
5 1
6...

output:

0
2
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
...

result:

wrong answer 4th numbers differ - expected: '2', found: '7'