# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
23046 | Bruteforceman | Bali Sculptures (APIO15_sculpture) | C++11 | 99 ms | 2092 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;
int a[2005];
int dp[2005];
int n, A, B;
typedef long long Long;
Long p[2005];
const int bit = 42;
long long mask;
const int inf = 1e8;
void solve (int x) {
mask ^= 1LL << x;
for(int i = 1; i <= n; i++) {
dp[i] = inf;
for(int j = 0; j < i; j++) {
long long sum = p[i] - p[j];
if((sum | mask) == mask) dp[i] = min(dp[i], dp[j] + 1);
}
}
if(dp[n] > B) {
mask |= (1LL << x);
}
}
int xp[105][105];
void fuck(int x) {
mask ^= 1LL << x;
memset(xp, 0, sizeof xp);
xp[0][0] = 1;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= i; j++) {
for(int k = 0; k < i; k++) {
long long sum = p[i] - p[k];
if((sum | mask) == mask) {
xp[i][j] |= xp[k][j - 1];
}
}
}
}
int cnt = 0;
for(int i = A; i <= B; i++) {
cnt |= xp[n][i];
}
if(!cnt) {
mask |= 1LL << x;
}
}
int main(int argc, char const *argv[])
{
scanf("%d %d %d", &n, &A, &B);
for(int i = 1; i <= n; i++) {
scanf("%d", a + i);
}
for(int i = 1; i <= n; i++) {
p[i] = p[i - 1] + a[i];
}
for(int i = 0; i <= bit; i++) {
mask |= 1LL << i;
}
for(int x = bit; x >= 0; x--) {
if(A == 1) solve(x);
else fuck(x);
}
printf("%lld\n", mask);
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... |