| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 91193 | sh25_shenpy | 异或和 | C++ | 通过 | 155 MS | 18224 KB | 1073 | 2026-06-12 15:15:20 |
#include<bits/stdc++.h> #define ll long long #define max(a,b) (a)>(b)?(a):(b) using namespace std; ll s[100005],a[100005]; ll f[2][1000005],n,m,ans=0,now,cnt=0,tmp; bool flag; ll maxn; inline void read(ll&x){ x=0; char ch=getchar(); while(!isdigit(ch)) ch=getchar(); for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0'; } inline void update(ll x,ll y){ for(;x<=1000000;x+=x&-x) f[y][x]++; } inline ll query(ll x,ll y){ ll ansd=0; for(;x;x-=x&-x) ansd+=f[y][x]; return ansd; } int main(){ read(n); for(ll i=1;i<=n;i++) read(s[i]),s[i]+=s[i-1],maxn=max(maxn,s[i]); for(ll i=0;i<=20;i++){ if((1<<i)>maxn) break; memset(f,0,sizeof(f)); flag=0,cnt=0; update(1,0); for(ll j=1;j<=n;j++){ tmp=s[j]&(1<<i); if(tmp) now=query(a[j]+1,0)+query(1000000,1)-query(a[j]+1,1); else now=query(a[j]+1,1)+query(1000000,0)-query(a[j]+1,0); if(now%2) cnt^=1; update(a[j]+1,(tmp>0?1:0)); a[j]|=tmp; } if(cnt) ans+=(1<<i); } cout<<ans; return 0; }