#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);
for (auto &i : a)
cin >> i;
int q;
cin >> q;
vector<int> l(q), r(q), x(q);
for (int i = 0; i < q; i++) {
cin >> l[i] >> r[i] >> x[i]; l[i]--; r[i]--;
}
int ans = 0;
for (int mk = 0; mk < 1 << q; mk++) {
vector<int> v = a;
for (int i = 0; i < q; i++) {
if ((mk >> i) & 1) {
for (int j = l[i]; j <= r[i]; j++)
v[j] ^= x[i];
}
}
for (int i = 0; i < n; i++) {
int sm = 0;
for (int j = i; j < n; j++) {
sm = (sm + v[j]) % md;
ans = (ans + (ll)sm * sm % md) % md;
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 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 |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 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 |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
28 ms |
336 KB |
Output is correct |
7 |
Correct |
28 ms |
336 KB |
Output is correct |
8 |
Correct |
29 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
1616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2059 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2045 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2045 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 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 |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
28 ms |
336 KB |
Output is correct |
7 |
Correct |
28 ms |
336 KB |
Output is correct |
8 |
Correct |
29 ms |
336 KB |
Output is correct |
9 |
Execution timed out |
2045 ms |
336 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 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 |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
28 ms |
336 KB |
Output is correct |
7 |
Correct |
28 ms |
336 KB |
Output is correct |
8 |
Correct |
29 ms |
336 KB |
Output is correct |
9 |
Execution timed out |
2045 ms |
336 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 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 |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
28 ms |
336 KB |
Output is correct |
7 |
Correct |
28 ms |
336 KB |
Output is correct |
8 |
Correct |
29 ms |
336 KB |
Output is correct |
9 |
Incorrect |
14 ms |
1616 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |