#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 400005
#define ff first
#define ss second
#define pb push_back
#define sz(s) (int)s.size()
const int M = 1e9 + 7;
ll n, t, T, a[N], c[N], d[N], sum, q, x[N], y[N], l[N];
void solve(int b) {
if(b == q+1) {
for(int i = 1; i<= n;i++) {
d[i] = a[i];
}
for(int i = 1; i <= q; i++) {
if(c[i]) {
for(int j = x[i]; j <= y[i]; j++) {
d[j] = (d[j]^l[i]);
}
}
}
for(int i = 1; i <= n; i++) {
int jog = 0;
for(int j = i; j <= n; j++) {
jog += d[j];
sum += jog * jog;
sum %= M;
}
}
return;
}
c[b] = 1;
solve(b + 1);
c[b] = 0;
solve(b + 1);
}
int main () {
ios::sync_with_stdio(0);cin.tie(0);
cin >> n;
for(int i =1;i <= n;i++) {
cin >> a[i];
}
cin >> q;
for(int i = 1;i<=q;i++) {
cin >> x[i] >> y[i] >> l[i];
}
solve(1);
cout << sum << '\n';
}
# | 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... |