# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
75466 | MiricaMatei | Bali Sculptures (APIO15_sculpture) | C++14 | 118 ms | 5596 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>
using namespace std;
const int MAX_N = 2005;
int v[MAX_N];
int dp1[MAX_N];
bool dp[MAX_N][MAX_N];
int n;
long long pref;
bool check1(int bit, int b) {
dp1[0] = 0;
for (int i = 1; i <= n; ++i) {
dp1[i] = b + 1;
long long s = 0;
for (int j = i; j >= 1; --j) {
s += v[j];
if (dp1[j - 1] != b + 1 && (s & pref) == 0)
dp1[i] = min(dp1[i], 1 + dp1[j - 1]);
}
}
return dp1[n] <= b;
}
bool check2(int bit, int a, int b) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= i; ++j) {
long long s = 0;
for (int k = i; k >= j - 1; --k) {
s += v[k];
if (dp[k - 1][j - 1] == 1 && (s & pref) == 0) {
dp[i][j] = 1;
break;
}
}
}
}
for (int i = a; i <= b; ++i)
if (dp[n][i]) {
return 1;
}
return 0;
}
bool sePoate(int bit, int a, int b) {
pref |= (1LL << bit);
if (a == 1)
return check1(bit, b);
else
return check2(bit, a, b);
}
int main() {
int a, b;
scanf("%d%d%d", &n, &a, &b);
for (int i = 1; i <= n; ++i)
scanf("%d", &v[i]);
for (int i = 41; i >= 0; --i) {
if (!sePoate(i, a, b)) {
pref ^= (1LL << i);
}
}
printf("%lld", ((1LL << 42) - 1) ^ pref);
return 0;
}
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... |