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 LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e18;
const int mod=1e9+7;
int n,ans=0;
vector<int> v(N);
void cal(){
int total=0;
for(int i=0;i<n;i++){
int cnt=0;
for(int j=i;j<n;j++){
cnt+=v[j];
total+=cnt*cnt;
total%=mod;
}
}
ans+=total;
ans%=mod;
}
int32_t main() {
LCBorz;
cin>>n;
for(int i=0;i<n;i++){
cin>>v[i];
}
int q;cin>>q;
vector<int> a(q),b(q),c(q);
for(int i=0;i<q;i++){
cin>>a[i]>>b[i]>>c[i];
}
for(int mask=0;mask<(1<<q);mask++){
for(int i=0;i<q;i++){
if(mask&(1<<i)){
for(int j=a[i]-1;j<b[i];j++){
v[j]^=c[i];
}
}
}
cal();
for(int i=0;i<q;i++){
if(mask&(1<<i)){
for(int j=a[i]-1;j<b[i];j++){
v[j]^=c[i];
}
}
}
}
cout<<ans<<endl;
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... |