Submission #781441

#TimeUsernameProblemLanguageResultExecution timeMemory
781441ZHIRDILBILDIZIntergalactic ship (IZhO19_xorsum)C++14
17 / 100
2058 ms3412 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...