/**
____ ____ ____ __________________ ____ ____ ____
||I || ||c || ||e || || || ||M || ||a || ||n ||
||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__||
|/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\|
*/
#include <iostream>
#include <chrono>
#include <stack>
#include <vector>
#define endl '\n'
#define maxn 1000005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define mod (int)(1e9 + 7)
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair <ll, int> pli;
typedef long double ld;
std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;
double timePassed()
{
using namespace std::chrono;
currT = high_resolution_clock::now();
double time = duration_cast<duration<double>>(currT - startT).count();
return time * TIME_MULT;
}
template <typename T>
T power2(T num)
{
return num * num;
}
int n, q;
ll a[maxn], pref[maxn];
int l[maxn], r[maxn], x[maxn];
void read()
{
cin >> n;
for(int i = 0; i < n; i++)
cin >> a[i];
cin >> q;
for(int i = 0; i < q; i++)
{
cin >> l[i] >> r[i] >> x[i];
l[i]--;
r[i]--;
}
}
void solve()
{
ll sum = 0;
for(int mask = 0; mask < (1 << q); mask++)
{
for(int bit = 0; bit < q; bit++)
if(mask & (1 << bit))
{
pref[l[bit]] ^= x[bit];
pref[r[bit] + 1] ^= x[bit];
}
for(int i = 1; i < n; i++)
pref[i] ^= pref[i - 1];
for(int i = 0; i < n; i++)
a[i] ^= pref[i];
ll cur = 0 , pom = 0;
for(int i = 0; i < n; i++)
{
pom = 0;
for(int j = i; j < n; j++)
{
pom += a[j];
cur += power2(pom);
cur %= mod;
}
}
sum += cur;
sum %= mod;
for(int i = 0; i < n; i++)
{
a[i] ^= pref[i];
pref[i] = 0;
}
}
cout << sum << endl;
}
void combine()
{
int t;
cin >> t;
//while(t--)
//read_solve();
}
int main()
{
/**#ifdef ONLINE_JUDGE
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
#endif*/
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
///startT = std::chrono::high_resolution_clock::now();
read();
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
18 ms |
6492 KB |
Output is correct |
7 |
Correct |
18 ms |
6492 KB |
Output is correct |
8 |
Correct |
18 ms |
6616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
10840 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2070 ms |
6492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1641 ms |
6600 KB |
Output is correct |
2 |
Correct |
1644 ms |
6492 KB |
Output is correct |
3 |
Correct |
1644 ms |
6596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1641 ms |
6600 KB |
Output is correct |
2 |
Correct |
1644 ms |
6492 KB |
Output is correct |
3 |
Correct |
1644 ms |
6596 KB |
Output is correct |
4 |
Incorrect |
3 ms |
6744 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
18 ms |
6492 KB |
Output is correct |
7 |
Correct |
18 ms |
6492 KB |
Output is correct |
8 |
Correct |
18 ms |
6616 KB |
Output is correct |
9 |
Correct |
1641 ms |
6600 KB |
Output is correct |
10 |
Correct |
1644 ms |
6492 KB |
Output is correct |
11 |
Correct |
1644 ms |
6596 KB |
Output is correct |
12 |
Incorrect |
70 ms |
6488 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
18 ms |
6492 KB |
Output is correct |
7 |
Correct |
18 ms |
6492 KB |
Output is correct |
8 |
Correct |
18 ms |
6616 KB |
Output is correct |
9 |
Correct |
1641 ms |
6600 KB |
Output is correct |
10 |
Correct |
1644 ms |
6492 KB |
Output is correct |
11 |
Correct |
1644 ms |
6596 KB |
Output is correct |
12 |
Incorrect |
3 ms |
6744 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
18 ms |
6492 KB |
Output is correct |
7 |
Correct |
18 ms |
6492 KB |
Output is correct |
8 |
Correct |
18 ms |
6616 KB |
Output is correct |
9 |
Incorrect |
13 ms |
10840 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |