답안 #126388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126388 2019-07-07T15:18:45 Z The_Wolfpack Bali Sculptures (APIO15_sculpture) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int NMAX=2007;

int n,a,b;
int dp[NMAX];
int dp1[105][105]; 
ll y[NMAX],parc[NMAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>a>>b;
    for(int i=0;i<n;i++) cin>>y[i];
    parc[0]=y[0];
    for(int i=1;i<n;i++) parc[i]=parc[i-1]+y[i]; 
    if(a==1)
    {
        ll res=0;
        for(int i=40;i>=0;i--)
        {
            ll cur=res | (1ll<<i);
            for(int j=0;j<=n;j++) dp[j]=n+1;
            dp[0]=0;
            for(int j=0;j<n;j++)
            {
                ll sum=0;
                for(int k=j;k<n;k++)
                {
                    sum+=y[k];
                    if((sum&cur)==0) dp[k+1]=min(dp[k+1],dp[j]+1);
                }
            }
            if(dp[n]<=b) res+=(1ll<<i);
        }

    cout<<(1ll<<41)-1-res<<endl;
    }
    else
    {
        ll res=0; 
        for(int i=40;i>=0;i--)
        {
            ll cur=res|(1ll<<i); 
            memset(dp1,0,sizeof(dp1)); 
            for(int t=0;t<n;t++) if((cur&parc[t])==0) dp1[t][1]=1; 
            for(int t=2;t<=n;t++) 
            {
                for(int j=0;j<n;j++)
                {
                    ll sum=0; 
                    for(int k=j;k<n;k++) 
                    {
                        sum+=y[k]; 
                        if((cur&sum)==0 && dp1[j+1][t-1]) dp1[k+1][t]=1; 
                    }
                }
            }
            for(int t=a;t<=b;t++)
            {
                if(dp[n][t]) 
                {
                    res+=(1ll<<i);
                    break; 
                }
            }
        }
        ll res=0;
        for(int i=40;i>=0;i--)
        {
            ll cur=res | (1ll<<i);
            for(int j=0;j<=n;j++) dp[j]=n+1;
            dp[0]=0;
            for(int j=0;j<n;j++)
            {
                ll sum=0;
                for(int k=j;k<n;k++)
                {
                    sum+=y[k];
                    if((sum&cur)==0) dp[k+1]=min(dp[k+1],dp[j]+1);
                }
            }
            if(dp[n]<=b) res+=(1ll<<i);
        }

    cout<<(1ll<<41)-1-res<<endl;
    }
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:63:27: error: invalid types 'int[int]' for array subscript
                 if(dp[n][t]) 
                           ^
sculpture.cpp:70:12: error: redeclaration of 'long long int res'
         ll res=0;
            ^~~
sculpture.cpp:43:12: note: 'long long int res' previously declared here
         ll res=0; 
            ^~~