#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 105;
int n, a[N], q, l[N], r[N], x[N], pre[N], ans;
int main(){
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i];
cin >> q;
for (int i = 0; i < q; ++i) {
cin >> l[i] >> r[i] >> x[i], --l[i], --r[i];
}
for (int i = 0; i < (1 << q); ++i) {
for (int j = 0; j < q; ++j) {
if (i & 1 << j) {
pre[l[j]] ^= x[j];
pre[r[j] + 1] ^= x[j];
}
}
for (int i = 1; i < n; ++i) pre[i] ^= pre[i - 1];
for (int i = 0; i < n; ++i) a[i] ^= pre[i];
int sum = 0;
for (int i = 0; i < n; ++i) {
int cur = 0;
for (int j = i; j < n; ++j) {
cur += a[j];
sum += cur * cur;
sum %= MOD;
}
}
ans += sum;
ans %= MOD;
for (int i = 0; i < n; ++i) {
a[i] ^= pre[i];
pre[i] = 0;
}
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
19 ms |
348 KB |
Output is correct |
7 |
Correct |
19 ms |
348 KB |
Output is correct |
8 |
Correct |
19 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1804 ms |
412 KB |
Output is correct |
2 |
Correct |
1771 ms |
344 KB |
Output is correct |
3 |
Correct |
1758 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1804 ms |
412 KB |
Output is correct |
2 |
Correct |
1771 ms |
344 KB |
Output is correct |
3 |
Correct |
1758 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
19 ms |
348 KB |
Output is correct |
7 |
Correct |
19 ms |
348 KB |
Output is correct |
8 |
Correct |
19 ms |
348 KB |
Output is correct |
9 |
Correct |
1804 ms |
412 KB |
Output is correct |
10 |
Correct |
1771 ms |
344 KB |
Output is correct |
11 |
Correct |
1758 ms |
348 KB |
Output is correct |
12 |
Execution timed out |
2078 ms |
348 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
19 ms |
348 KB |
Output is correct |
7 |
Correct |
19 ms |
348 KB |
Output is correct |
8 |
Correct |
19 ms |
348 KB |
Output is correct |
9 |
Correct |
1804 ms |
412 KB |
Output is correct |
10 |
Correct |
1771 ms |
344 KB |
Output is correct |
11 |
Correct |
1758 ms |
348 KB |
Output is correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
19 ms |
348 KB |
Output is correct |
7 |
Correct |
19 ms |
348 KB |
Output is correct |
8 |
Correct |
19 ms |
348 KB |
Output is correct |
9 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |