QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#64780 | #4810. Add One | ckiseki# | WA | 2ms | 3512kb | C++17 | 1019b | 2022-11-25 15:50:04 | 2022-11-25 15:50:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void Elim(vector<int64_t> &b, int64_t &x) {
for (int64_t y: b) {
x = min(x, x ^ y);
}
}
void Insert(vector<int64_t> &b, int64_t x) {
Elim(b, x);
if (x) {
b.push_back(x);
}
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<int64_t> bs;
int64_t xo = 0;
for (int i = 0; i < n; i++) {
int64_t x;
cin >> x;
Insert(bs, x);
xo ^= x;
}
int64_t ans = -1e18;
for (int len = 0; len <= 60; len++) {
auto B = bs;
for (int64_t &y: B) y &= (1LL << (len + 1)) - 1;
int64_t x = (1LL << len) - 1;
const int64_t val = (1LL << (len + 1)) - 1;
// cerr << "B = ";
// for (int64_t &y: B) cerr << y << ',';
// cerr << endl;
// cerr << "x = " << x << endl;
Elim(B, x);
if (not x) {
ans = max(ans, xo ^ val);
}
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3488kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3356kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3512kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 2ms
memory: 3360kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: 0
Accepted
time: 2ms
memory: 3436kb
input:
6 56 90 61 63 56 23
output:
112
result:
ok 1 number(s): "112"
Test #8:
score: 0
Accepted
time: 2ms
memory: 3336kb
input:
7 8 83 78 19 36 6 22
output:
205
result:
ok 1 number(s): "205"
Test #9:
score: -100
Wrong Answer
time: 2ms
memory: 3344kb
input:
7 23 23 22 78 2 29 88
output:
30
result:
wrong answer 1st numbers differ - expected: '32', found: '30'