#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1005;
const int MAX_Q = 1e5 + 5;
const int MOD = 1e9 + 7;
int A[MAX_N];
long long qs[MAX_N], qs2[MAX_N];
int L[MAX_Q], R[MAX_Q], X[MAX_Q];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N;
cin >> N;
for(int i = 1; i <= N; i++) {
cin >> A[i];
}
int Q;
cin >> Q;
for(int i = 0; i < Q; i++) {
cin >> L[i] >> R[i] >> X[i];
}
long long ans = 0;
for(int mask = 0; mask < (1<<Q); mask++) {
for(int i = 1; i <= N; i++) {
qs[i] = 0;
}
for(int q = 0; q < Q; q++) {
if(mask & (1<<q)) {
qs[L[q]] ^= X[q];
qs[R[q] + 1] ^= X[q];
}
}
for(int i = 1; i <= N; i++) {
qs[i] ^= qs[i - 1];
qs2[i] = qs2[i - 1] + (A[i] ^ qs[i]);
}
long long sum2 = 0, sum1 = 0;
for(int i = 1; i <= N; i++) {
ans += i * qs2[i] * qs2[i] - 2 * qs2[i] * sum1 + sum2;
ans %= MOD;
sum1 += qs2[i];
sum1 %= MOD;
sum2 += qs2[i] * qs2[i];
sum2 %= MOD;
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
2252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2079 ms |
340 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
320 ms |
340 KB |
Output is correct |
2 |
Correct |
308 ms |
340 KB |
Output is correct |
3 |
Correct |
318 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
320 ms |
340 KB |
Output is correct |
2 |
Correct |
308 ms |
340 KB |
Output is correct |
3 |
Correct |
318 ms |
340 KB |
Output is correct |
4 |
Incorrect |
3 ms |
444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
320 ms |
340 KB |
Output is correct |
10 |
Correct |
308 ms |
340 KB |
Output is correct |
11 |
Correct |
318 ms |
340 KB |
Output is correct |
12 |
Incorrect |
7 ms |
340 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
320 ms |
340 KB |
Output is correct |
10 |
Correct |
308 ms |
340 KB |
Output is correct |
11 |
Correct |
318 ms |
340 KB |
Output is correct |
12 |
Incorrect |
3 ms |
444 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
17 ms |
2252 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |