Submission #48635

# Submission time Handle Problem Language Result Execution time Memory
48635 2018-05-17T13:44:06 Z okaybody10 Bali Sculptures (APIO15_sculpture) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2007;
ll partsum[N];
bool dp2[N][N];
int n,A,B,dp[N],bit[60];
bool solve()
{
    ll val=0;
    for(int i=0;i<50;i++) val+=bit[i]*(1LL<<i);
    if(A==1)
    {
        dp[0]=0;
        for(int i=1;i<=n;i++)
        {
            dp[i]=N;
            for(int j=0;j<i;j++)
            {
                if(((partsum[i]-partsum[j]) | val)== val) dp[i]=min(dp[i],dp[j]+1);
            }
        }
        if(dp[n]<=B) return true;
        return false;
    }
    dp2[0][0]=true;
    for(int i=1;i<=n;i++) dp2[i][0]=false;
    for(int i=1;i<=B;i++) dp2[0][i]=false;
    for(int i=1;i<=n;i++)
    {
        dp2[i][j]=false;
        for(int j=1;j<=B;j++)
        {
            for(int k=0;k<i;k++)
            {
                if(dp2[k][j-1] && ((partsum[i]-partsum[k])| val) == val)  {
                    dp2[i][j]=true;
                    break;
                }
            }
        }
    }
    for(int i=A;i<=B;i++)
        if(dp2[n][i]) return true;
    return false;
}
int main()
{
    cin>>n>>A>>B;
    for(int i=1,x;i<=n;i++) cin>>x, partsum[i]=partsum[i-1]+x;
    for(int i=0;i<50;i++) bit[i]=1;
    for(int i=49;i>=0;i--)
    {
        bit[i]=0;
        bool ok=solve(); if(!ok) bit[i]=1;
    }
    ll res=0;
    for(int i=0;i<50;i++) res+=bit[i]*(1LL<<i);
    cout<<res<<endl;
}

Compilation message

sculpture.cpp: In function 'bool solve()':
sculpture.cpp:31:16: error: 'j' was not declared in this scope
         dp2[i][j]=false;
                ^