QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#390755 | #4810. Add One | Beater | WA | 1ms | 3724kb | C++20 | 1.1kb | 2024-04-15 21:12:25 | 2024-04-15 21:12:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
const int MAXN=1e5+7;
const int INF = 0x3f3f3f3f;
typedef long long ll;
#define endl "\n"
typedef unsigned long long ull;
vector<ull> B;
void insert(ull x) {
for (auto b : B)
x = min(x, b ^ x);
for (auto &b : B)
b = min(b, b ^ x);
if (x)
B.push_back(x);
}
int check(int x,int lim){
for(auto b:B){
int t=x;
for(int i=0;i<=lim;i++){
if((b>>i)&1){
t^=1ll<<i;
}
}
x=min(x,t);
}
if(x==0){
return 1;
}else{
return 0;
}
}
void solve(){
int n;
cin>>n;
ll a[n+1];
ll cnt=0;
for(int i=1;i<=n;i++){
cin>>a[i];
insert(a[i]);
cnt^=a[i];
}
sort(B.begin(),B.end());
ll ans=0;
for(int i=0;i<=60;i++){
if(check((1ll<<i)-1,i)){
ans=max(ans,cnt^((1ll<<(i+1))-1));
}
}
cout<<ans<<endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3660kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
6 56 90 61 63 56 23
output:
112
result:
ok 1 number(s): "112"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
7 8 83 78 19 36 6 22
output:
205
result:
ok 1 number(s): "205"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
7 23 23 22 78 2 29 88
output:
32
result:
ok 1 number(s): "32"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
7 109 80 14 27 9 45 24
output:
235
result:
ok 1 number(s): "235"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
7 144 152 137 143 145 139 183
output:
220
result:
ok 1 number(s): "220"
Test #12:
score: -100
Wrong Answer
time: 1ms
memory: 3660kb
input:
7 189 270 119 372 240 144 153
output:
74
result:
wrong answer 1st numbers differ - expected: '78', found: '74'