QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#448196#8520. Xor Partitionsucup-team3651#WA 1ms3656kbC++201.1kb2024-06-19 14:02:122024-06-19 14:02:13

Judging History

你现在查看的是最新测评结果

  • [2024-06-19 14:02:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3656kb
  • [2024-06-19 14:02:12]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define N 300005
#define mod 1000000007
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0' && ch>'9')f=(ch=='-'?-1:f),ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return x*f;
}
void write(ll x){
    if(x<0)x=-x,putchar('-');
    if(x/10)write(x/10);
    putchar(x%10+'0');
}
ll a[N];
ll g[N][2];
void insert(ll it,ll c){
    for(ll i=62;i>=0;i--){
        ll j=(it&(1ll<<i)?1:0);
        g[i][j]=(g[i][j]+c)%mod;
    }
}
ll ask(ll it){
    ll res=0;
    for(ll i=62;i>=0;i--){
        ll j=(it&(1ll<<i)?1:0);
        res+=(g[i][j^1]*((1ll<<i)%mod))%mod;
    }
    return res;
}
ll f[N];
int main(){
    #ifdef EAST_CLOUD
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    #endif
    ll n=read();
    for(ll i=1;i<=n;i++)a[i]=read(),a[i]^=a[i-1];
    insert(0,1);
    for(ll i=1;i<=n;i++){
        f[i]=ask(a[i]);insert(a[i],f[i]);
        //cerr<<i<<' '<<f[i]<<' '<<a[i]<<endl;
    }
    write(f[n]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3604kb

input:

4
7 3 1 2

output:

170

result:

ok 1 number(s): "170"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

1
0

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

3
1 2 3

output:

16

result:

ok 1 number(s): "16"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

4
0 1 0 1

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3656kb

input:

562
918479109239293921 960173570446350728 374394588863436385 418106819278123099 473761712658352147 662782574081105364 824954323015093862 827581845536521847 184394794881199801 820907621998888642 606529830885621237 961790689782125501 582742201855597942 337901250755571075 287706594894797714 18578215893...

output:

30641941868

result:

wrong answer 1st numbers differ - expected: '641941658', found: '30641941868'