QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#453746#8823. Game: Battle of Menjis5abWA 45ms3640kbC++201.1kb2024-06-24 10:23:212024-06-24 10:23:25

Judging History

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

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

answer

/* name: K
 * author: 5ab
 * created at: 2024-06-24
 */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))

auto chmax = [](auto& x, auto y) { if (x < y) x = y; };
auto chmin = [](auto& x, auto y) { if (y < x) x = y; };

using ll = long long;
const int N = 1e5, lgA = 30;

int a[N], c[lgA];

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int cas, n, k;
	
	auto lb = [&](int x) { return x ? __lg(x & -x) + 1 : 0; };
	auto gm = [&](int x) { return (1 << x) - 1; };
	
	cin >> cas;
	while (cas--)
	{
		cin >> n >> k;
		fill(c, c + lgA, 0);
		
		int sm = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
			c[lb(a[i])]++;
			sm ^= a[i];
		}
		int ans = 0;
		for (int i = 0; i < n; i++)
		{
			int cv = sm, lbc = lb(a[i] + 1);
			c[lb(a[i])]--, c[lbc]++;
			for (int j = 0; j < lgA; j++) if (c[j])
			{
				chmin(cv, sm ^ gm(j) ^ gm(lbc));
				// cerr << j << " " << lbc << " " << cv << endl;
			}
			chmax(ans, cv);
			c[lb(a[i])]++, c[lbc]--;
		}
		cout << ans << endl;
	}
	
	return 0;
}
// started coding at: 06-24 10:09:52

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 45ms
memory: 3572kb

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
2
3
0
1
3
6
5
4
4
2
5
3
0
7
2
0
3
0
2
5
4
3
4
7
0
3
2
4
4
4
2
4
6
1
3
2
7
4
7
4
6
2
4
4
3
7
0
2
2
1
0
6
7
0
0
1
7
1
3
3
6
2
1
5
5
5
1
6
4
1
2
0
7
1
4
3
6
7
7
0
1
7
0
0
4
0
4
7
7
6
4
6
2
5
4
7
4
1
6
4
4
3
4
7
5
4
4
3
6
1
2
5
4
2
1
1
0
0
0
0
6
1
3
4
0
1
4
6
2
1
3
5
1
0
6
3
2
1
4
5
2
1
2
2
7
6
7
...

result:

wrong answer 93rd numbers differ - expected: '7', found: '6'