QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#371911 | #4810. Add One | _mjj | WA | 1ms | 3672kb | C++20 | 1.2kb | 2024-03-30 17:55:30 | 2024-03-30 17:55:31 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define int long long
using namespace std;
typedef long long LL;
typedef pair<int , int> PII;
const int N = 1e6 + 5;
const int mod = 998244353;
const int INF = 0x3f3f3f3f;
int a[N] , d[105];
void insert(int x) {
for(int i=0;i<=62;i++) {
if(x>>i&1) {
if(d[i]) x^=d[i];
else {
d[i]=x;
return ;
}
}
}
}
bool check(int x){
int s = 0;
for(int i = 0 ; i <= 60 ; i ++){
if((x >> i & 1) == (s >> i & 1))continue;
if(d[i] == 0)return 0;
s = s ^ d[i];
}
return 1;
}
void solve(){
int n;
cin >> n;
int res = 0;
int s = 0;
for(int i = 1 ; i <= n ; i ++)cin >> a[i] , s ^= a[i];
for(int i = 1 ; i <= n ; i ++)insert(a[i]);
for(int i = 0 ; i <= 60 ; i ++){
if(check((1ll << i) - 1))res = max(res , ((1ll << (i + 1)) - 1) ^ s);
}
cout << res << endl;
}
signed main(){
ios;
int T = 1;
// cin >> T;
while(T --){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3656kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3672kb
input:
6 56 90 61 63 56 23
output:
78
result:
wrong answer 1st numbers differ - expected: '112', found: '78'