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;
ll ans = OO;
for(int x = a; x <= b; ++x) {
ll f = 0;
for(char bt = 38; ~bt; --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) < PW(bt)) g[l][e[l]++] = r + 1;
}
}
m = 1; q[0] = 0;
fo(x) {
if(!m) { fail = true; break; }
set<int> h;
for(int v = 0; v < m; ++v)
for(int u = 0; u < e[q[v]]; ++u) h.insert(g[q[v]][u]);
m = 0; for(int v : h) q[m++] = v;
}
if(!m || q[m - 1] != n) fail = true;
if(fail) f ^= PW(bt);
}
umin(ans, f);
}
cout << ans << endl;
}
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... |