# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
498214 | sireanu_vlad | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 3076 ms | 332 KiB |
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 <iostream>
using namespace std;
int mod = 1e9 + 7;
int n, a[1001], q, res, s[100001][3];
void read()
{
cin >> n;
for(int i = 1; i <= n; ++i)
cin >> a[i];
cin >> q;
for(int i = 1; i <= q; ++i)
cin >> s[i][1] >> s[i][2] >> s[i][3];
}
void sum()
{
for(int i = 1; i <= n; ++i)
for(int j = i, p; j <= n; ++j)
{
p = 0;
for(int k = i; k <= j; ++k)
p = (p + a[k]) % mod;
res = (res + (p*p%mod)) % mod;
}
}
void up(int l, int r, int x)
{
for(int i = l; i <= r; ++i)
a[i] ^= x;
}
void back(int k)
{
if(k == 0)
sum();
if(k > 0)
{
up(s[k][1], s[k][2], s[k][3]);
back(k - 1);
up(s[k][1], s[k][2], s[k][3]);
back(k - 1);
}
}
int main()
{
read();
back(q);
cout << res;
return 0;
}
Compilation message (stderr)
# | 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... |