QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140626 | #4810. Add One | XY_Eleven | WA | 1ms | 3884kb | C++23 | 3.5kb | 2023-08-16 14:46:26 | 2023-08-16 14:46:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(3)
#define DB double
#define LL long long
#define ULL unsigned long long
#define pii pair<int,int>
#define pil pair<int,LL>
#define mii map<int,int>
#define miig map<int,int,greater<int> >
#define mil map<int,LL>
#define in128 __int128
#define cint const int
#define cLL const LL
#define cDB const DB
#define cchar const char
#define invoid inline void
#define inLL inline LL
#define inlint inline int
#define inbool inline bool
#define inl128 inline __int128
#define inDB inline double
#define For(z,e1,e2) for(int z=(e1);z<=(e2);z++)
#define Rof(z,e1,e2) for(int z=(e2);z>=(e1);z--)
#define For_(z,e1,e2) for(int z=(e1);z<(e2);z++)
#define Rof_(z,e1,e2) for(int z=(e2);z>(e1);z--)
#define inint(e) scanf("%d",&e)
#define inll(e) scanf("%lld",&e)
#define inpr(e1,e2) scanf("%d%d",&e1,&e2)
#define in3(e1,e2,e3) scanf("%d%d%d",&e1,&e2,&e3)
#define outint(e) printf("%d\n",e)
#define outint_(e) printf("%d%c",e," \n"[i==n])
#define outll(e) printf("%lld\n",e)
#define outll_(e) printf("%lld%c",e," \n"[i==n])
#define exc(e) if(e) continue
#define stop(e) if(e) break
#define ret(e) if(e) return
#define ll(e) ((LL)(e))
#define pb push_back
#define ft first
#define sc second
#define clean(e) while(!e.empty()) e.pop()
#define all(ev) ev.begin(),ev.end()
#define x0 x00
#define y1 y11
#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define fout fflush(stdout)
invoid input(int &N_,int A_[],bool F_)
{
if(F_) inint(N_);
For(i,1,N_) inint(A_[i]);
}
template <typename Type>
inline Type md(Type w1,const Type w2)
{
w1%=w2; if(w1<0) w1+=w2;
return w1;
}
template <typename Type>
invoid add(Type &w1,const Type w2,const Type M_)
{ w1=md(w1+w2,M_); }
invoid mul(LL &w1,cLL w2,cLL M_)
{ w1=md(w1*w2,M_); }
inLL gcd(LL X_,LL Y_)
{
LL R_=X_%Y_;
while(R_)
{ X_=Y_; Y_=R_; R_=X_%Y_; }
return Y_;
}
invoid ex_gcd(LL &X_,LL &Y_,LL A_,LL B_)
{
if(!B_)
{
X_=1ll; Y_=0ll;
return ;
}
ex_gcd(Y_,X_,B_,A_%B_);
X_=md(X_,B_); Y_=(1ll-X_*A_)/B_;
}
inLL inv(LL A_,LL B_)
{
LL X_=0ll,Y_=0ll;
ex_gcd(X_,Y_,A_,B_);
return X_;
}
inLL pw(LL X_,LL Y_,LL M_)
{
LL S_=1ll;
while(Y_)
{
if(Y_&1) mul(S_,X_,M_);
Y_>>=1;
mul(X_,X_,M_);
}
return S_;
}
template <typename Type>
invoid get_min(Type &w1,const Type w2)
{ if(w2<w1) w1=w2; }
template <typename Type>
invoid get_max(Type &w1,const Type w2)
{ if(w2>w1) w1=w2; }
//inLL A(cint N_,cint M_)
//{ return (N_>=M_?md(d1[N_]*d2[N_-M_],mod):0ll); }
//inLL C(cint N_,cint M_)
//{ return (N_>=M_?md(d1[N_]*md(d2[M_]*d2[N_-M_],mod),mod):0ll); }
//mt19937 gen(time(NULL));
//mt19937_64 gen(time(NULL));
//cLL base[]={166686661,188868881},mod[]={1686688681,1666868881};
//cLL base[]={166686661,188868881},mod[]={1686688681,1666868881},inter=1861;
//cLL mod[]={1e9+7,1e9+9,1e9+21,1e9+33};
//cLL mod=998244353;
cint N=1.02e6,K=60;
int n;
LL d[K],t;
int main()
{
inint(n);
LL s=0ll;
while(n--)
{
inll(t);
s^=t;
Rof(i,0,K-1)
{
exc(!(t>>i&1));
if(d[i]) t^=d[i];
else { d[i]=t; break; }
}
}
// For_(i,0,K) outll(d[i]);
LL ans=0ll;
For_(i,0,K)
{
LL h=(1ll<<i)-1ll;
Rof(j,0,i)
if(h>>j&1)
h^=d[j];
if(!h) get_max(ans,s^((1ll<<i+1)-1ll));
}
outll(ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3884kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
5 41 40 50 11 36
output:
99
result:
ok 1 number(s): "99"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
6 10 40 60 2 44 47
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
6 46 25 39 47 23 60
output:
107
result:
ok 1 number(s): "107"
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 3868kb
input:
6 56 90 61 63 56 23
output:
78
result:
wrong answer 1st numbers differ - expected: '112', found: '78'