QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#469221 | #8520. Xor Partitions | kmiao | WA | 113ms | 18568kb | C++20 | 826b | 2024-07-09 16:22:17 | 2024-07-09 16:22:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = __int128;
using vi = vector<int>;
#define pb push_back
const int N = 3e5 + 5;
const ll m = 1e9 + 7;
int n;
long long a[N];
map<pair<ll, ll>, ll> mp;
ll f(int i, ll base) {
base = base ^ a[i] % m;
if (mp.find({i, base}) != mp.end()) {
return mp[{i, base}];
}
if (i < n-1) {
mp[{i, base}] = (base * f(i+1, 0) % m + f(i+1, base) % m) % m;
return mp[{i, base}];
}
mp[{i, base}] = base % m;
return mp[{i, base}];
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] %= m;
}
ll ans = f(0, 0) % m;
if (ans < 0) ans += m;
long long res = ans;
cout << res << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
4 7 3 1 2
output:
170
result:
ok 1 number(s): "170"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
1 0
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
3 1 2 3
output:
16
result:
ok 1 number(s): "16"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
4 0 1 0 1
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: -100
Wrong Answer
time: 113ms
memory: 18568kb
input:
562 918479109239293921 960173570446350728 374394588863436385 418106819278123099 473761712658352147 662782574081105364 824954323015093862 827581845536521847 184394794881199801 820907621998888642 606529830885621237 961790689782125501 582742201855597942 337901250755571075 287706594894797714 18578215893...
output:
95157266
result:
wrong answer 1st numbers differ - expected: '641941658', found: '95157266'