# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
690576 | iskhakkutbilim | Intergalactic ship (IZhO19_xorsum) | C++14 | 2077 ms | 3424 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 ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 1000;
const int M = 1e9+7;
struct upd{
int l, r, x;
};
vector<upd> query;
int n, q, a[N];
int count_K(){
int sum = 0;
for(int i = 0;i < n; i++){
int s = 0;
for(int j = i;j < n; j++){
s+= a[j];
sum = (sum + s*s)%M;
}
}
return sum;
}
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 0;i < n; i++){
cin >> a[i];
}
cin >> q;
query.resize(q);
for(int i = 0;i < q; i++){
cin >> query[i].l >> query[i].r >> query[i].x;
query[i].l--, query[i].r--;
}
int answer = 0;
for(int mask = 0; mask < (1<<q); mask++){
for(int i = 0;i < q; i++){
if(mask & (1<<i)){
for(int j = query[i].l; j <= query[i].r; j++){
a[j] = (a[j] ^ query[i].x);
}
}
}
answer = (answer + count_K())%M;
for(int i = 0;i < q; i++){
if(mask & (1<<i)){
for(int j = query[i].l; j <= query[i].r; j++){
a[j] = (a[j] ^ query[i].x);
}
}
}
}
cout << answer;
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |