Submission #369293

# Submission time Handle Problem Language Result Execution time Memory
369293 2021-02-21T07:05:51 Z Bill_00 Bali Sculptures (APIO15_sculpture) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
typedef long long ll;
#define N 2005
using namespace std;
ll x[N],n,a,b,sum[N];
bool dp[N][N]
int dpp[N];
bool check(ll mask){
	if(a>1){
		for(ll i=1;i<=n;i++){
			for(ll j=1;j<=n;j++){
				dp[i][j]=0;
			}
		}
		dp[0][0]=1;
		for(ll i=1;i<=n;i++){
			for(ll j=1;j<=i;j++){
				for(ll k=1;k<=i;k++){
					if(dp[k-1][j-1]==1 && ((mask)&(sum[i]-sum[k-1]))==(sum[i]-sum[k-1])){
						dp[i][j]=1;
					}
				}
			}
		}
		for(ll i=a;i<=b;i++){
			if(dp[n][i]==1) return 1;
		}
		return 0;
	}
	else{
		dpp[0]=0;
		for(ll i=1;i<=n;i++){
			dpp[i]=n+1;
		}
		for(ll i=1;i<=n;i++){
			for(ll j=1;j<=i;j++){
				if(dpp[j-1]!=n+1 && ((mask)&(sum[i]-sum[j-1]))==(sum[i]-sum[j-1])){
					dpp[i]=min(dpp[i],dpp[j-1]+1);
				}
			}
		}
		if(dpp[n]<=b) return 1;
		else return 0;
	}
}
int main() {
	cin >> n >> a >> b;
	for(ll i=1;i<=n;i++){
		cin >> x[i];
		sum[i]=sum[i-1]+x[i];
	}
	ll ans=(1LL<<62)-1;
	for(ll i=61;i>=0;i--){
		if(check(ans-(1LL<<i))){
			ans-=(1LL<<i);
		}
	}
	cout << ans;
}

Compilation message

sculpture.cpp:7:1: error: expected initializer before 'int'
    7 | int dpp[N];
      | ^~~
sculpture.cpp: In function 'bool check(ll)':
sculpture.cpp:12:5: error: 'dp' was not declared in this scope
   12 |     dp[i][j]=0;
      |     ^~
sculpture.cpp:15:3: error: 'dp' was not declared in this scope
   15 |   dp[0][0]=1;
      |   ^~
sculpture.cpp:31:3: error: 'dpp' was not declared in this scope
   31 |   dpp[0]=0;
      |   ^~~
sculpture.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^