#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
const int MAX_N = 1010, p = 1e9 + 7, MAX_Q = 100010;
int n, a[MAX_N], q, l[MAX_N], r[MAX_N], x[MAX_N];
ll pf[MAX_N];
int brute_force() {
ll res = 0;
for (int s = 0;s < 1<<q;++s) {
fill(pf, pf+n+1, 0);
for (int i = 0;i < q;++i) if (s >> i & 1)
pf[ l[i] ] ^= x[i], pf[ r[i]+1 ] ^= x[i];
for (int i = 1;i <= n;++i)
pf[i] ^= pf[i-1];
for (int i = 1;i <= n;++i)
pf[i] = (pf[i] ^ a[i]) + pf[i-1];
for (int i = 0;i <= n;++i)
for (int j = i+1;j <= n;++j)
res = (res + (pf[j] - pf[i]) * (pf[j] - pf[i])) % p;
//
// for (int i = 1;i <= n;++i)
// res = (res + 1ll * pf[i] * pf[i] % p * (n+1)) % p;
//
// res = (res + 1ll * pf[n] * pf[n]) % p;
}
return res;
}
int32_t main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n;
for (int i = 1;i <= n;++i)
cin >> a[i];
cin >> q;
for (int i = 0;i < q;++i)
cin >> l[i] >> r[i] >> x[i];
if (q > 20) return 1;
cout << brute_force() << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
22 ms |
364 KB |
Output is correct |
7 |
Correct |
21 ms |
384 KB |
Output is correct |
8 |
Correct |
21 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
364 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
364 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
22 ms |
364 KB |
Output is correct |
7 |
Correct |
21 ms |
384 KB |
Output is correct |
8 |
Correct |
21 ms |
364 KB |
Output is correct |
9 |
Execution timed out |
2075 ms |
364 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
22 ms |
364 KB |
Output is correct |
7 |
Correct |
21 ms |
384 KB |
Output is correct |
8 |
Correct |
21 ms |
364 KB |
Output is correct |
9 |
Execution timed out |
2075 ms |
364 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
22 ms |
364 KB |
Output is correct |
7 |
Correct |
21 ms |
384 KB |
Output is correct |
8 |
Correct |
21 ms |
364 KB |
Output is correct |
9 |
Runtime error |
1 ms |
364 KB |
Execution failed because the return code was nonzero |
10 |
Halted |
0 ms |
0 KB |
- |