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>
void solve() {
int n, a, b; cin >> n >> a >> b;
ll y[n]; fo(n) cin >> y[i];
if(n > 100) {
const int N = 2000;
typedef bitset<N + 1> bi;
bi g[n + 1];
ll ans = 0;
for(char bt = 44; ~bt; --bt) {
ll mx = PW(bt);
bool fail = false;
for(int l = 0; l < n; ++l) {
ll sum = 0;
for(int r = l; r < n; ++r) {
sum += y[r];
g[l][r + 1] = (sum & ~ans) < mx;
}
}
bi q; q[0] = 1;
fo(b) {
if(q[n]) break;
bi t;
fo(n) if(q[i]) t |= g[i];
q = t;
}
if(!q[n]) fail = true;
if(fail) ans ^= mx;
}
cout << ans << endl;
} else {
const int N = 100;
typedef bitset<N + 1> bi;
bi g[n + 1];
ll ans = OO;
for(int x = a; x <= b; ++x) {
ll f = 0;
for(char bt = 38; ~bt; --bt) {
ll mx = PW(bt);
bool fail = false;
for(int l = 0; l < n; ++l) {
ll sum = 0;
for(int r = l; r < n; ++r) {
sum += y[r];
g[l][r + 1] = (sum & ~f) < mx;
}
}
bi q; q[0] = 1;
fo(x) {
bi t;
fo(n) if(q[i]) t |= g[i];
q = t;
}
if(!q[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();
}
# | 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... |