QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#391041 | #4810. Add One | xunxxxx | WA | 0ms | 3692kb | C++20 | 636b | 2024-04-16 12:29:24 | 2024-04-16 12:29:25 |
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;
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";
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3620kb
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: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
7 23 23 22 78 2 29 88
output:
31
result:
wrong answer 1st numbers differ - expected: '32', found: '31'