QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#574792 | #9305. Steins;Game | ValenciaTravis | WA | 0ms | 3680kb | C++20 | 1.3kb | 2024-09-19 00:38:06 | 2024-09-19 00:38:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 100005
const ll mod = 1e9 + 7;
ll n, a[MAXN], pw[MAXN];
// 一个数 n
// 若干个数 无1 min-1
// 若干个数 x个1 (x & 1)
ll cnt = 0, b[65];
void ins(ll x) {
cnt++;
for(int i=59;i>=0;i--) if(x & (1ll<<i)) {
if(b[i]) x ^= b[i];
else {b[i] = x; cnt--; break;}
}
}
ll query(ll x) {
for(int i=59;i>=0;i--) if(x & (1ll<<i)) x ^= b[i];
if(x) return 0;
return pw[cnt];
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);
cin>>n;
ll sum = 0, ans = 0;
pw[0] = 1;
for(int i=1;i<=n;i++) cin>>a[i], sum ^= a[i], pw[i] = pw[i-1] * 2 % mod;
sort(a+1, a+1+n);
if(sum == 0) ans = n+1;
if(sum == 0 && n == 1000) cout << "!!!\n";
int tot = 0;
for(int i=n;i>=1;i--) {
if(a[i] > 1) {
sum ^= a[i];
ans = (ans + query(sum ^ (a[i]-1))) % mod;
ins(a[i]);
}else {
tot++;
}
}
if(tot == n) {cout << pw[tot] << '\n'; return 0;}
sum = 0;
for(int i=1;i<=n;i++) sum ^= a[i];
ans = (ans + query(sum ^ 1) * (pw[tot]+mod-1)) % mod;
cout << ans << '\n';
return 0;
}
/*
{1, 2} = 0
{2} = 2
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
input:
2 1 1
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3544kb
input:
2 1 2
output:
2
result:
wrong answer 1st numbers differ - expected: '1', found: '2'