#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const int MAXN = 1008;
const ll MOD = 1000000007;
int a[MAXN];
signed main() {
int n;
cin >> n;
for (int i = 0; i < n; ++i)
cin >> a[i];
int q;
cin >> q;
vector<pair<pair<int, int>, int>> qrs(q);
for (int i = 0; i < q; ++i) {
cin >> qrs[i].first.first >> qrs[i].first.second >> qrs[i].second;
--qrs[i].first.first;
}
ll ans = 0;
for (int m = 0; m < (1 << q); ++m) {
vector<int> b(n);
for (int i = 0; i < n; ++i)
b[i] = a[i];
for (int j = 0; j < q; ++j) {
if (m & (1 << j)) {
auto [sg, x] = qrs[j];
for (int i = sg.first; i < sg.second; ++i) {
b[i] ^= x;
}
}
}
for (int i = 0; i < n; ++i) {
int sm = 0;
for (int j = i; j < n; ++j) {
sm += b[j];
ans += 1ll * sm * sm;
ans %= MOD;
//cout << sm << ' ';
}
}
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
22 ms |
280 KB |
Output is correct |
7 |
Correct |
21 ms |
296 KB |
Output is correct |
8 |
Correct |
22 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
49 ms |
2224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2087 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2074 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2074 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
22 ms |
280 KB |
Output is correct |
7 |
Correct |
21 ms |
296 KB |
Output is correct |
8 |
Correct |
22 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
2074 ms |
212 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
22 ms |
280 KB |
Output is correct |
7 |
Correct |
21 ms |
296 KB |
Output is correct |
8 |
Correct |
22 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
2074 ms |
212 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
22 ms |
280 KB |
Output is correct |
7 |
Correct |
21 ms |
296 KB |
Output is correct |
8 |
Correct |
22 ms |
212 KB |
Output is correct |
9 |
Incorrect |
49 ms |
2224 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |