QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#716786 | #8520. Xor Partitions | yhddd | WA | 0ms | 7920kb | C++14 | 1.2kb | 2024-11-06 16:02:40 | 2024-11-06 16:02:40 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define db double
using namespace std;
const int maxn=200010;
const int inf=1e18;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
return x*f;
}
bool Mbe;
int n,a[maxn];
int dp[maxn],s[maxn];
int sum[65][2],pw[65];
void work(){
n=read();
for(int i=1;i<=n;i++)a[i]=read(),s[i]=s[i-1]^a[i];
pw[0]=1;for(int i=1;i<=n;i++)pw[i]=pw[i-1]*2%mod;
dp[0]=1;
for(int i=0;i<=60;i++)sum[i][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=60;j++){
int v=(s[i]>>j)&1ll;
(dp[i]+=sum[j][v^1]*pw[j])%=mod;
}
for(int j=0;j<=60;j++)(sum[j][(s[i]>>j)&1ll]+=dp[i])%=mod;
}
printf("%lld\n",dp[n]);
}
// \
444
bool Med;
int T;
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
// cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
T=1;
while(T--)work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5856kb
input:
4 7 3 1 2
output:
170
result:
ok 1 number(s): "170"
Test #2:
score: 0
Accepted
time: 0ms
memory: 7920kb
input:
1 0
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 5808kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 5868kb
input:
3 1 2 3
output:
16
result:
ok 1 number(s): "16"
Test #5:
score: 0
Accepted
time: 0ms
memory: 5864kb
input:
4 0 1 0 1
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 5944kb
input:
562 918479109239293921 960173570446350728 374394588863436385 418106819278123099 473761712658352147 662782574081105364 824954323015093862 827581845536521847 184394794881199801 820907621998888642 606529830885621237 961790689782125501 582742201855597942 337901250755571075 287706594894797714 18578215893...
output:
614148158
result:
wrong answer 1st numbers differ - expected: '641941658', found: '614148158'