-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadjxor2.cpp
More file actions
25 lines (25 loc) · 774 Bytes
/
adjxor2.cpp
File metadata and controls
25 lines (25 loc) · 774 Bytes
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
#include <bits/stdc++.h>
#define ln long long
using namespace std;
int main()
{
ln num;
cin >> num;
while (num--)
{
ln num1, k, post, str1[200001], output[200001][2];
cin >> num1;
cin >> post;
for (k = 1; k <= num1; k++)
cin >> str1[k];
for (k = 2; k <= num1; k++)
{
output[k][0] = max(output[k - 1][0] + (str1[k - 1] ^ str1[k]),
output[k - 1][1] + ((str1[k - 1] + post) ^ str1[k]));
output[k][1] = max(output[k - 1][0] + (str1[k - 1] ^ (str1[k] + post)),
output[k - 1][1] + ((str1[k - 1] + post) ^ (str1[k] + post)));
}
cout << max(output[num1][0], output[num1][1])
<< "\n";
}
}