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>
#define fi first
#define se second
#define lc id<<1
#define rc id<<1^1
const long long inf = 1e18;
using namespace std;
typedef pair<int, int> pii;
const long long mx = (1LL << 41) - 1;
int n, l, r;
long long a[2008], orr[2008][2008];
long long ans = 0;
bitset<2008>f[2008];
bool check(int x){
f[0].reset();
f[0].set(0);
for (int j = 1; j <= r; j++){
for (int i = 0; i <= n; i++)
if (i < j)
f[j].reset(i);
else{
f[j].reset(i);
for (int pos = 1; pos <= i && !f[j].test(i); pos++)
if (!(x & orr[pos][i]) && f[j - 1].test(pos - 1))
f[j].set(i);
}
if (f[j].test(n) && j >= l)
return true;
}
return false;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> l >> r;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
orr[i][j] = orr[i][j - 1] + a[j];
for (long long i = 1LL << 41; i > 0; i >>= 1)
ans += i * check(ans + i);
cout << (int)(mx ^ ans);
return 0;
}
# | 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... |