Submission #961395

#TimeUsernameProblemLanguageResultExecution timeMemory
961395pccIntergalactic ship (IZhO19_xorsum)C++17
17 / 100
272 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const ll mod = 1e9+7; const int mxn = 1010; const int B = 7; vector<int> ori; array<int,3> req[mxn*100]; int N,Q; ll ans = 0; ll mad(ll a,ll b){ a += b; return a>=mod?a-mod:a; } ll mub(ll a,ll b){ return mad(a,mod-b); } ll calc(vector<int> v){ ll sq = 0,sum = 0,sum2 = 0; for(auto &i:v){ sum = mad(sum,i); sum2 += sum; sq = mad(sq,sum*sum%mod); } return mub(sq*(N+1)%mod,sum2*sum2%mod); } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N; ori.resize(N); for(int i = 0;i<N;i++)cin>>ori[i]; cin>>Q; if(Q>20)return 0; for(int i = 0;i<Q;i++)cin>>req[i][0]>>req[i][1]>>req[i][2],req[i][0]--,req[i][1]--; for(int i = 0;i<(1<<Q);i++){ auto tmp = ori; for(int j = 0;j<Q;j++){ if(i&(1<<j)){ for(int k = req[j][0];k<=req[j][1];k++)tmp[k]^=req[j][2]; } } ans = mad(ans,calc(tmp)); } cout<<ans<<'\n'; 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...