#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const long long MAXN = 500;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
long long n, m;
long long a[MAXN], aa[MAXN];
long long ql[MAXN], qr[MAXN], xx[MAXN];
long long mod = 1e9 + 7, total = 0;
void apply(long long subset)
{
for (long long i = 1; i <= n; ++ i)
aa[i] = a[i];
for (long long i = 0; i < m; ++ i)
{
if((1 << i) & subset)
{
for (long long j = ql[i]; j <= qr[i]; ++ j)
aa[j] = (aa[j] ^ xx[i]);
}
}
long long ans = 0;
for (long long i = 1; i <= n; ++ i)
{
long long current = 0;
for (long long j = i; j <= n; ++ j)
{
current += aa[j];
current %= mod;
ans += current * current;
ans %= mod;
}
}
total += ans;
total %= mod;
}
void read()
{
cin >> n;
for (long long i = 1; i <= n; ++ i)
{
cin >> a[i];
}
long long pow = 1;
cin >> m;
for (long long i = 0; i < m; ++ i)
{
pow *= 2;
cin >> ql[i] >> qr[i] >> xx[i];
}
for (long long i = 0; i < pow; ++ i)
{
apply(i);
}
cout << total% mod << endl;
}
int main()
{
speed();
read();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
25 ms |
472 KB |
Output is correct |
7 |
Correct |
25 ms |
348 KB |
Output is correct |
8 |
Correct |
24 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2052 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2045 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2084 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2084 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
25 ms |
472 KB |
Output is correct |
7 |
Correct |
25 ms |
348 KB |
Output is correct |
8 |
Correct |
24 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
2084 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
25 ms |
472 KB |
Output is correct |
7 |
Correct |
25 ms |
348 KB |
Output is correct |
8 |
Correct |
24 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
2084 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
25 ms |
472 KB |
Output is correct |
7 |
Correct |
25 ms |
348 KB |
Output is correct |
8 |
Correct |
24 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
2052 ms |
344 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |