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];
ll ans = OO;
for(int x = a; x <= b; ++x) {
ll f = 0;
for(char bt = 39; ~bt; --bt) {
bool fail = false;
vi g[n + 1];
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].pb(r + 1);
}
}
vi q(1, 0);
fo(x) {
if(q.empty()) { fail = true; break; }
set<int> h;
for(int v : q) for(int u : g[v]) h.insert(u);
q.resize(0);
for(int v : h) q.pb(v);
}
if(q.empty() || q.back() != 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... |