This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=105, mod=1e9+7;
ll n, q, a[nx], t[nx], qs[nx], l[nx], r[nx], x[nx], res;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
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];
for (int msk=0; msk<(1<<q); msk++)
{
ll sm=0;
for (int i=1; i<=n; i++) t[i]=a[i];
for (int i=0; i<q;i ++) if (msk&(1<<i)) for (int j=l[i]; j<=r[i]; j++) t[j]=t[j]^x[i];
for (int i=1; i<=n; i++) qs[i]=(qs[i-1]+t[i])%mod, res=(res+(((n+1)*qs[i])%mod*(qs[i]))%mod), sm+=qs[i];
sm=(sm*sm%mod);
sm=((-sm)%mod+mod)%mod;
res=(res+sm)%mod;
}
cout<<res;
}
# | 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... |