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;
const int MOD=1e9+7;
signed main(){
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++) cin>>a[i];
int q;
cin>>q;
vector<array<int,3>>queries(q);
long long ans=0;
for(int i=0;i<q;i++){
cin>>queries[i][0]>>queries[i][1]>>queries[i][2];
}
for(int mask=0;mask<(1<<q);mask++){
vector<int>b=a;
for(int i=0;i<q;i++){
if(mask>>i & 1){
for(int j=queries[i][0]-1;j<queries[i][1];j++) b[j]^=queries[i][2];
}
}
for(int i=0;i<n;i++){
long long s=0;
for(int j=i;j<n;j++){
s+=b[j];
ans+=s*s;
ans%=MOD;
}
}
}
cout<<ans;
}
# | 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... |