This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//{ <defines>
#ifndef _LOCAL
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#endif
#include <bits/stdc++.h>
using namespace std;
#define fr(i, n) for(int i = 0; i < n; ++i)
#define fo(n) fr(i, n)
#define re return
#define ef else if
#define ifn(x) if(!(x))
#define _ << ' ' <<
#define ft first
#define sd second
#define ve vector
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define pw(x) (1 << (x))
#define PW(x) (1ll << (x))
#define bnd(x) x.begin(), x.end()
#define clr(x, y) memset(x, y, sizeof x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef ve<int> vi;
const int oo = 2e9;
const ll OO = 4e18;
//const ld pi = arg(complex<ld>(-1, 0));
//const ld pi2 = pi + pi;
const int md = 0x3b800001;
const int MD = 1e9 + 7;
inline ll time() {re chrono :: system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
mt19937_64 RND(time());
template<typename t> inline void umin(t &a, t b) {a = min(a, b);}
template<typename t> inline void umax(t &a, t b) {a = max(a, b);}
//} </defines>
const int N = 2e5 + 228;
void solve() {
int n, a, b; cin >> n >> a >> b;
ll y[n]; fo(n) cin >> y[i];
int g[n + 1][n]; clr(g, 0); int e[n + 1];
int q[n]; int m;
int h[n * n + 5]; int t;
if(n > 100) {
ll ans = 0;
for(char bt = 38; ~bt; --bt) {
ll mx = mx = PW(bt);
bool fail = false;
clr(e, 0);
for(int l = 0; l < n; ++l) {
ll sum = 0;
for(int r = l; r < n; ++r) {
sum += y[r];
if((sum & ~ans) < mx) g[l][e[l]++] = r + 1;
}
}
m = 1; q[0] = 0;
for(; m; ) {
if(q[m - 1] == n) break;
t = 0;
for(int v = 0; v < m; ++v)
for(int u = 0; u < e[q[v]]; ++u)
h[t++] = g[q[v]][u];
sort(h, h + t);
t = unique(h, h + t) - h;
m = 0;
for(int v = 0; v < t; ++v)
q[m++] = h[v];
}
if(!m || q[m - 1] != n) fail = true;
if(fail) ans ^= mx;
}
cout << ans << endl;
} else {
ll ans = OO;
for(int x = a; x <= b; ++x) {
ll f = 0;
for(char bt = 38; ~bt; --bt) {
ll mx = mx = PW(bt);
bool fail = false;
clr(e, 0);
for(int l = 0; l < n; ++l) {
ll sum = 0;
for(int r = l; r < n; ++r) {
sum += y[r];
if((sum & ~f) < mx) g[l][e[l]++] = r + 1;
}
}
m = 1; q[0] = 0;
fo(x) {
if(!m) { fail = true; break; }
t = 0;
for(int v = 0; v < m; ++v)
for(int u = 0; u < e[q[v]]; ++u)
h[t++] = g[q[v]][u];
sort(h, h + t);
t = unique(h, h + t) - h;
m = 0;
for(int v = 0; v < t; ++v)
q[m++] = h[v];
}
if(!m || q[m - 1] != n) fail = true;
if(fail) f ^= mx;
}
umin(ans, f);
}
cout << ans << endl;
}
}
/*
6 1 3
8 1 2 1 5 4
*/
int main() {
solve();
}
Compilation message (stderr)
sculpture.cpp: In function 'void solve()':
sculpture.cpp:65:24: warning: operation on 'mx' may be undefined [-Wsequence-point]
ll mx = mx = PW(bt);
^
sculpture.cpp:105:28: warning: operation on 'mx' may be undefined [-Wsequence-point]
ll mx = mx = PW(bt);
^
# | 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... |