# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78028 | xiaowuc1 | Bali Sculptures (APIO15_sculpture) | C++14 | 1076 ms | 1672 KiB |
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>
/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/
using namespace std;
const double PI = 2 * acos(0);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, ll> pill;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<vector<ll>> matrix;
ll pref[2001];
int n, lhs, rhs;
bool valid[2001];
bool nextValid[2001];
bool can(ll mask) {
memset(valid, 0, sizeof(valid));
valid[0] = true;
for(int x = 1; x <= rhs; x++) {
memset(nextValid, 0, sizeof(nextValid));
for(int a = 0; a <= n; a++) {
if(!valid[a]) continue;
for(int b = a+1; b <= n; b++) {
ll vv = pref[b] - pref[a];
nextValid[b] |= (vv&mask)==vv;
}
}
if(x >= lhs && nextValid[n]) return true;
memcpy(valid, nextValid, sizeof(valid));
}
return false;
}
int main() {
scanf("%d%d%d", &n, &lhs, &rhs);
for(int i = 0; i < n; i++) {
scanf("%lld", &pref[i+1]);
pref[i+1] += pref[i];
}
ll ret = 1LL << 60;
ret--;
for(int i = 59; i >= 0; i--) {
ll ans = ret ^ (1LL << (i));
if(can(ans)) {
ret = ans;
}
}
printf("%lld\n", ret);
}
Compilation message (stderr)
# | 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... |