QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225264 | #4810. Add One | JerryBlack_ZJNU | WA | 0ms | 3868kb | C++23 | 1.3kb | 2023-10-24 12:47:10 | 2023-10-24 12:47:10 |
Judging History
answer
#include <bits/stdc++.h>
#include <ctime>
//#define endl '\n'
#define ll long long //unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define PI acos(-1)
#define rep(i,n,m) for(int i=n;i<=m;i++)
#define per(i,n,m) for(int i=n;i>=m;i--)
#define bug1(i) cerr<<i<<endl
#define bug2(i,j) cerr<<i<<" "<<j<<endl
#define bug3(i,j,k) cerr<<i<<" "<<j<<" "<<k<<endl
#define bug4(i,j,k,l) cerr<<i<<" "<<j<<" "<<k<<" "<<l<<endl
#define mod 1000000007 //998244353.1000000007
#define maxn 1000005
#define eps 1e-6
using namespace std;
ll b[65];
bool flag;
void insert(ll x) // 插入数字,获取线性基
{
for(int i=0;i<=60;i++) if(x>>i&1){
if(!b[i]){
b[i]=x;
return;
}
else x^=b[i];
}
flag=true;
}
void solve(){
int n;
cin>>n;
ll ans=0;
rep(i,1,n){
ll x;cin>>x;
// cout<<x<<endl;
ans^=x;
insert(x);
}
for(int i=0;i<=60;i++){
if(!b[i]){
ans^=((1LL<<i)-1);
ans^=(1LL<<i);
break;
}
}
cout<<ans<<endl;
}
/*
*/
void init(){
}
signed main(){
#ifdef LOCAL
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int ca=1;clock_t c1=clock();
init();
// cin>>ca;
while(ca--){
solve();
}
// cerr<<"Time used:"<<clock()-c1<<"ms"<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3736kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3868kb
input:
5 41 40 50 11 36
output:
35
result:
wrong answer 1st numbers differ - expected: '99', found: '35'