# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
382243 | BartolM | Intergalactic ship (IZhO19_xorsum) | C++17 | 2080 ms | 3164 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 X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;
const int INF=0x3f3f3f3f;
const int LOG=7;
const int N=1005;
const int MOD=1e9+7;
const int Q=1e5+5;
int add(int a, int b) {
a+=b;
if (a>=MOD) a-=MOD;
return a;
}
int mul(int a, int b) {
return (ll)a*b%MOD;
}
int n, q;
int p[N], np[N];
vector <ppi> que;
#define DEBUG 0
void solve() {
int sol=0;
for (int mask=0; mask<(1<<q); ++mask) {
for (int i=0; i<n; ++i) np[i]=p[i];
for (int i=0; i<q; ++i) {
if ((1<<i) & mask) {
for (int j=que[i].X.X; j<=que[i].X.Y; ++j) np[j]=np[j]^que[i].Y;
}
}
for (int i=0; i<n; ++i) {
for (int j=i; j<n; ++j) {
int interi=mul(i+1, n-j);
if (i!=j) interi=mul(interi, 2);
int curr=mul(np[i], np[j]);
sol=add(sol, mul(curr, interi));
}
}
}
printf("%d\n", sol);
}
void load() {
scanf("%d", &n);
for (int i=0; i<n; ++i) scanf("%d", p+i);
scanf("%d", &q);
for (int i=0; i<q; ++i) {
int l, r, x;
scanf("%d %d %d", &l, &r, &x); l--; r--;
que.pb(mp(mp(l, r), x));
}
}
int main() {
load();
assert(q<=20);
// pot[0]=1;
// for (int i=1; i<=q; ++i) pot[i]=mul(pot[i-1], 2);
solve();
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... |