-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprev.cpp
More file actions
65 lines (53 loc) · 1.22 KB
/
prev.cpp
File metadata and controls
65 lines (53 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <bits/stdc++.h>
using namespace std;
#define MAINRET(x) in##x
#define what_is(x) cout << #x << " is " << x << endl;
#define print_vec(x, n) for (int i = 0; i < n; i++) cout << x[i] << ' '; cout << endl;
#define LL long long
#define arr2 array<int,2>
#define arr3 array<int,3>
void solve();
MAINRET(t) main(void) {
std::cin.tie(nullptr);
std::cin.sync_with_stdio(false);
solve();
}
constexpr int INF = (int)1e9 + 100;
constexpr LL LINF = std::numeric_limits<LL>::max() / 2;
constexpr int NINF = -INF;
constexpr int MX = 2 * 1e5 + 1;
constexpr int MD = (int)1e9 + 7;
LL n, m, k, q;
vector<LL> nums;
vector<LL> tmp;
LL ans = 0;
void dfs(int idx, int ct, LL x) {
if (ct == 0) {
ans = max(ans, x);
return;
}
if (n - idx < ct) return;
for (int i = idx; i < n - ct + 1; i++) {
dfs(i + 1, ct - 1, x ^ nums[i]);
}
}
void solve() {
cin >> n >> k;
nums = vector<LL>(n);
for (int i = 0; i < n; i++) {
LL x; cin >> x;
nums[i] = x;
}
if (n - k < k) {
LL tot = 0;
for (int i = 0; i < n; i++) {
tot ^= nums[i];
}
dfs(0, n-k, tot);
} else {
dfs(0, k, 0);
}
cout << ans << '\n';
}
/*
*/