#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define PI 3.14159265359
ll n,m,t,p,sum[1001],a[1001],b[1001],c,d,e,f,i,j,k,mod=1000000007,mod1=998244353,MAX=1e18,ans,q,l[100001],r[100001],x[100001];
string s,u;
ll df[101];
vector<ll>v;
vector<ll>dv[101];
void dfs(ll x){
df[x]=1;
for(ll i=0;i<dv[x].size();i++){
if(df[dv[x][i]]==0){
dfs(dv[x][i]);
}
}
}
ll fastPow(ll a,ll b){
ll d=1;
while(b>0){
if(b%2==1){
d=d*a%mod;
}
b/=2;
a=a*a%mod;
}
return d;
}
ll check(){
sum[0]=0;
for(ll i=1;i<=n;i++){
sum[i]=sum[i-1]+b[i];
}
ll ans=0;
for(ll i=1;i<=n;i++){
for(ll j=i;j<=n;j++){
ans=(ans+(sum[j]-sum[i-1])*(sum[j]-sum[i-1]))%mod;
}
}
return ans;
}
int main(){
cin>>n;
for(i=1;i<=n;i++){
cin>>a[i];
}
cin>>q;
for(i=1;i<=q;i++){
cin>>l[i]>>r[i]>>x[i];
}
f=fastPow(2,q);
ans=0;
for(i=1;i<=f;i++){
d=i;
for(j=1;j<=n;j++){
b[j]=a[j];
}
for(j=1;j<=q;j++){
if(d%2==1){
for(k=l[j];k<=r[j];k++){
b[k]^=x[j];
}
}
d/=2;
}
ans=(ans+check())%mod;
}
cout<<ans;
}
Compilation message
xorsum.cpp: In function 'void dfs(long long int)':
xorsum.cpp:15:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(ll i=0;i<dv[x].size();i++){
| ~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
25 ms |
328 KB |
Output is correct |
7 |
Correct |
24 ms |
328 KB |
Output is correct |
8 |
Correct |
24 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2078 ms |
3352 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2084 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2086 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2086 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
25 ms |
328 KB |
Output is correct |
7 |
Correct |
24 ms |
328 KB |
Output is correct |
8 |
Correct |
24 ms |
204 KB |
Output is correct |
9 |
Execution timed out |
2086 ms |
204 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
25 ms |
328 KB |
Output is correct |
7 |
Correct |
24 ms |
328 KB |
Output is correct |
8 |
Correct |
24 ms |
204 KB |
Output is correct |
9 |
Execution timed out |
2086 ms |
204 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
25 ms |
328 KB |
Output is correct |
7 |
Correct |
24 ms |
328 KB |
Output is correct |
8 |
Correct |
24 ms |
204 KB |
Output is correct |
9 |
Execution timed out |
2078 ms |
3352 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |