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>
#define ll long long
using namespace std ;
const ll mod = 1e9 + 7 ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
ll n, q, all = 0 ;
cin >> n ;
ll a[n + 1] ;
for(ll i = 1 ; i <= n ; i++)
cin >> a[i] ;
cin >> q ;
ll l[q + 1], r[q + 1], x[q + 1] ;
for(ll i = 0 ; i < q ; i++)
cin >> l[i] >> r[i] >> x[i] ;
for(ll i = 0 ; i < (1 << q) ; i++)
{
ll pref[n + 1] = {} ;
for(ll j = 0 ; j < q ; j++)
if((1 << j) & i)
{
for(ll z = l[j] ; z <= r[j] ; z++)
a[z] ^= x[j] ;
}
for(int j = 1 ; j <= n ; j++)
pref[j] = pref[j - 1] + a[j] ;
for(int j = 1 ; j <= n ; j++)
for(int z = j ; z <= n ; z++)
{
all += (pref[z] - pref[j - 1]) * (pref[z] - pref[j - 1]) ;
all %= mod ;
}
for(ll j = 0 ; j < q ; j++)
if((1 << j) & i)
{
for(ll z = l[j] ; z <= r[j] ; z++)
a[z] ^= x[j] ;
}
}
cout << all ;
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... |