Submission #43659

# Submission time Handle Problem Language Result Execution time Memory
43659 2018-03-19T07:33:59 Z top34051 Bali Sculptures (APIO15_sculpture) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;
const long long inf = 2e16 + 5;
int n,a,b;
int p[maxn];
int dp1[maxn], dp2[maxn][maxn];
bool check1(long long bit) {
//    printf("check %lld\n",bit);
    for(int x=1;x<=n;x++) {
        long long cur = 0;
        dp1[x] = n+1;
        for(int y=x;y>=1;y--) {
            cur += p[y];
            if((cur|bit) == bit) dp1[x] = min(dp1[x], dp1[y-1] + 1);
        }
//        printf("\tdp %d = %d\n",x,dp[x]);
    }
    return dp1[n]<=b;
}
bool check2(long long bit) {
//    printf("check %lld\n",bit);
    dp2[0][0] = 1;
    for(int x=1;x<=n;x++) {
        for(int k=1;k<=n;k++) {
            dp[x][k] = 0;
            long long cur = 0;
            for(int y=x;y>=1;y--) {
                cur += p[y];
                if((cur|bit) == bit) dp2[x][k] |= dp2[y-1][k-1];
            }
        }
    }
    for(int k=a;k<=b;k++) if(dp2[n][k]) return 1;
    return 0;
}
bool check(long long bit) {
    if(a==1) return check1(bit);
    return check2(bit);
}
int main() {
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]);
	long long res = (1LL<<41)-1;
	for(int i=40;i>=0;i--) {
        if(check(res-(1LL<<i))) res -= (1LL<<i);
	}
	printf("%lld",res);
}

Compilation message

sculpture.cpp: In function 'bool check2(long long int)':
sculpture.cpp:26:13: error: 'dp' was not declared in this scope
             dp[x][k] = 0;
             ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:42:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&a,&b);
                          ^
sculpture.cpp:43:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&p[i]);
                                         ^