# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037345 | Alfraganus | Intergalactic ship (IZhO19_xorsum) | C++17 | 2075 ms | 7420 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 <bits/stdc++.h>
using namespace std;
#define int long long
#define str string
#define fastio ios::sync_with_stdio(0), cin.tie(0);
#define fs first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define len(x) x.size()
#define print(a) \
for (auto &x : a) \
cout << x << " "; \
cout << endl;
#define printmp(a) \
for (auto &x : a) \
cout << x.fs << " " << x.ss << endl;
const int mod = 1e9 + 7;
vector<int> a;
vector<array<int, 3>> S;
int ans = 0;
void dfs(int p){
for(int i = 0; i < a.size(); i ++){
int sum = 0;
for(int j = i; j < a.size(); j ++){
sum += a[j];
sum %= mod;
ans = (ans + sum * sum) % mod;
}
}
for(int j = p; j < S.size(); j ++){
for(int x = S[j][0] - 1; x < S[j][1]; x ++)
a[x] ^= S[j][2];
dfs(j + 1);
for(int x = S[j][0] - 1; x < S[j][1]; x ++)
a[x] ^= S[j][2];
}
}
void solve(){
int n;
cin >> n;
a.resize(n);
for(int i = 0; i < n; i ++)
cin >> a[i];
int q;
cin >> q;
S.resize(q);
for(int i = 0; i < q; i ++)
cin >> S[i][0] >> S[i][1] >> S[i][2];
dfs(0);
cout << ans;
}
signed main()
{
fastio;
#ifdef Javohir
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t = 1;
// cin >> t;
while (t--)
{
solve();
cout << endl;
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |