QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225295 | #4810. Add One | JerryBlack_ZJNU | WA | 0ms | 3864kb | C++23 | 1.5kb | 2023-10-24 13:42:31 | 2023-10-24 13:42:31 |
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(){
// cout<<(28^127)<<endl;
int n;
cin>>n;
ll ans=0;
rep(i,1,n){
ll x;cin>>x;
ans^=x;
insert(x);
}
// cout<<ans<<endl;
// for(int i=0;i<7;i++) cout<<b[i]<<" ";cout<<endl;
ll tmp=-LINF,now=0;
for(int i=0;i<=60;i++){
if(now&(1LL<<i)) ;
else if(b[i]) now=now^b[i];
else{
// cout<<i<<endl;
ans^=((1ll<<(i+1))-1);
break;
}
// if(find())
}
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: 3864kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3716kb
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: 3728kb
input:
6 56 90 61 63 56 23
output:
48
result:
wrong answer 1st numbers differ - expected: '112', found: '48'