This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define f first
#define s second
#define pb push_back
#define ld long double
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vec vector
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
const ld eps = 1e-6;
const int mod = 1e9 + 7;
const int oo = 2e9;
const ll OO = 2e18;
const int N = 1e6 + 10;
struct Query
{
int l;
int r;
int x;
Query(int l, int r, int x) : l(l), r(r), x(x) {};
};
void add(int &x, int y)
{
x += y;
if (x >= mod) x %= mod;
}
void solve()
{
int n;
cin >> n;
vec<int> a(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
vec<Query> qs;
int q;
cin >> q;
for (int t = 0; t < q; t++)
{
int l, r, x;
cin >> l >> r >> x;
qs.pb(Query(l, r, x));
}
int ans = 0;
for (int mask = 0; mask < (1 << q); mask++)
{
vec<int> xr(n + 2);
for (int i = 0; i < q; i++)
{
if ((mask >> i) & 1)
{
xr[qs[i].l] ^= qs[i].x;
xr[qs[i].r + 1] ^= qs[i].x;
}
}
int p = 0;
vec<int> b(n + 1);
for (int i = 1; i <= n; i++)
{
p ^= xr[i];
b[i] = a[i] ^ p;
}
for (int i = 1; i <= n; i++)
{
int s = 0;
for (int j = i; j <= n; j++)
{
add(s, b[j]);
add(ans, s * s);
}
}
}
cout << ans;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |