QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#456837 | #8520. Xor Partitions | supepapupu | WA | 0ms | 3836kb | C++20 | 1.3kb | 2024-06-28 15:14:53 | 2024-06-28 15:14:53 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 1e9 + 7;
void inc(ll &a, ll b) {
a += b;
if (a >= mod) a -= mod;
}
void dec(ll &a, ll b) {
a -= b;
if (a < 0) a += mod;
}
ll add(ll a, ll b) {
a += b;
return a >= mod ? a - mod : a;
}
ll del(ll a, ll b) {
a -= b;
return a < 0 ? a + mod : a;
}
ll qmi(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
ll inv(ll a) {
return qmi(a, mod - 2);
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<vector<ll>> g(30, vector<ll>(2));
for (int i = 0; i < 30; ++i) g[i][0] = 1;
ll f;
int s = 0;
for (int i = 1; i <= n; ++i) {
int x; cin >> x;
s ^= x;
f = 0;
for (int j = 0; j < 30; ++j)
inc(f, (g[j][s >> j & 1 ^ 1] << j) % mod);
for (int j = 0; j < 30; ++j)
inc(g[j][s >> j & 1], f);
}
cout << f << el;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
4 7 3 1 2
output:
170
result:
ok 1 number(s): "170"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
1 0
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
3 1 2 3
output:
16
result:
ok 1 number(s): "16"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
4 0 1 0 1
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
562 918479109239293921 960173570446350728 374394588863436385 418106819278123099 473761712658352147 662782574081105364 824954323015093862 827581845536521847 184394794881199801 820907621998888642 606529830885621237 961790689782125501 582742201855597942 337901250755571075 287706594894797714 18578215893...
output:
39537273
result:
wrong answer 1st numbers differ - expected: '641941658', found: '39537273'