QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#391046 | #4810. Add One | xunxxxx | WA | 1ms | 3700kb | C++20 | 638b | 2024-04-16 12:32:56 | 2024-04-16 12:32:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,res,ans,t;
vector<int>b;
void insert(int x)
{
for(auto i:b) if((i^x)<x) x^=i;
if(x!=0) b.push_back(x);
}
int ck(int x,int l)
{
for(auto i:b)
{
if((x^(i-(i>>l<<l)))<x) x^=(i-(i>>l<<l));
}
if(x==0) return 1;
return 0;
}
signed main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>t;
ans^=t;
insert(t);
}
res=ans+1;
for(int i=1;i<=60;i++)
{
//01 ^11
//011 ^111
//0111 ^1111
if(ck((1ll<<i)-1,i))
{
// cout<<(1ll<<i)-1<<"\n";
res=max(res,ans^((1ll<<(i+1))-1));
}
}
cout<<res<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3580kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
6 56 90 61 63 56 23
output:
112
result:
ok 1 number(s): "112"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
7 8 83 78 19 36 6 22
output:
205
result:
ok 1 number(s): "205"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3632kb
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: 3636kb
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: 3576kb
input:
7 144 152 137 143 145 139 183
output:
220
result:
ok 1 number(s): "220"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
7 189 270 119 372 240 144 153
output:
78
result:
ok 1 number(s): "78"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
7 4819 2494 1822 4759 2622 4111 2460
output:
7510
result:
ok 1 number(s): "7510"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
8 83 20 17 43 52 78 68 45
output:
145
result:
ok 1 number(s): "145"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
8 289 205 96 274 304 476 230 246
output:
925
result:
ok 1 number(s): "925"
Test #16:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
8 6866 7210 3474 9147 7676 7287 7339 7605
output:
10311
result:
wrong answer 1st numbers differ - expected: '14267', found: '10311'