# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599293 | Plurm | Intergalactic ship (IZhO19_xorsum) | C++11 | 820 ms | 1960 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int a[1024];
int qs[1024];
int qqs[1024];
int qqss[1024];
const int MOD = 1e9 + 7;
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", a + i);
}
int q;
scanf("%d", &q);
vector<tuple<int, int, int>> updates;
for (int i = 0; i < q; i++) {
int l, r, x;
scanf("%d%d%d", &l, &r, &x);
updates.push_back({l, r, x});
}
if (q <= 20) {
int ans = 0;
int last = 0;
for (int bit = 0; bit < (1 << q); bit++) {
for (int i = 0; i < q; i++) {
if ((bit ^ last) & (1 << i)) {
int l, r, x;
tie(l, r, x) = updates[i];
for (int i = l; i <= r; i++) {
a[i] ^= x;
}
}
}
for (int i = 1; i <= n; i++) {
qs[i] = (qs[i - 1] + a[i]) % MOD;
}
for (int i = 1; i <= n; i++) {
qqs[i] = (qqs[i - 1] + qs[i]) % MOD;
qqss[i] = (qqss[i - 1] + 1ll * qs[i] * qs[i] % MOD) % MOD;
}
for (int i = 1; i <= n; i++) {
int k = (qqss[n] + MOD - qqss[i - 1]) % MOD +
(MOD - (2ll * qs[i - 1] * (qqs[n] - qqs[i - 1]) % MOD)) % MOD +
1ll * (n - i + 1) * qs[i - 1] % MOD * qs[i - 1] % MOD;
ans += k;
ans %= MOD;
}
last = bit;
}
printf("%d\n", ans);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |