#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int md = (int)1e9 + 7;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++)
cin >> a[i];
int q;
cin >> q;
vector<int> l(q + 1), r(q + 1), x(q + 1);
for (int i = 1; i <= q; i++)
cin >> l[i] >> r[i] >> x[i];
int ans = 0;
vector<int> v[1 << q];
v[0] = a;
for (int mk = 0; mk < 1 << q; mk++) {
for (int i = 1; i <= q; i++) {
if ((mk >> (i - 1)) & 1) {
v[mk] = v[mk ^ (1 << (i - 1))];
for (int j = l[i]; j <= r[i]; j++)
v[mk][j] ^= x[i];
break;
}
}
vector<int> p(n + 1);
for (int i = 1; i <= n; i++)
p[i] = p[i - 1] + v[mk][i];
int sm = 0, sms = 0;
for (int i = 1; i <= n; i++) {
int x = (ll)p[i] * p[i] % md;
ans = (ans + (((ll)i * x % md - (ll)p[i] * sm % md + md) % md + sms) % md) % md;
sms = (sms + x) % md;
sm = (sm + (p[i] << 1)) % md;
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
848 KB |
Output is correct |
7 |
Correct |
2 ms |
848 KB |
Output is correct |
8 |
Correct |
2 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
934 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
544 ms |
172720 KB |
Output is correct |
2 |
Correct |
545 ms |
172736 KB |
Output is correct |
3 |
Correct |
537 ms |
172616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
544 ms |
172720 KB |
Output is correct |
2 |
Correct |
545 ms |
172736 KB |
Output is correct |
3 |
Correct |
537 ms |
172616 KB |
Output is correct |
4 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
848 KB |
Output is correct |
7 |
Correct |
2 ms |
848 KB |
Output is correct |
8 |
Correct |
2 ms |
848 KB |
Output is correct |
9 |
Correct |
544 ms |
172720 KB |
Output is correct |
10 |
Correct |
545 ms |
172736 KB |
Output is correct |
11 |
Correct |
537 ms |
172616 KB |
Output is correct |
12 |
Incorrect |
8 ms |
2128 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
848 KB |
Output is correct |
7 |
Correct |
2 ms |
848 KB |
Output is correct |
8 |
Correct |
2 ms |
848 KB |
Output is correct |
9 |
Correct |
544 ms |
172720 KB |
Output is correct |
10 |
Correct |
545 ms |
172736 KB |
Output is correct |
11 |
Correct |
537 ms |
172616 KB |
Output is correct |
12 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
848 KB |
Output is correct |
7 |
Correct |
2 ms |
848 KB |
Output is correct |
8 |
Correct |
2 ms |
848 KB |
Output is correct |
9 |
Incorrect |
12 ms |
1616 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |