답안 #629785

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629785 2022-08-15T06:25:18 Z aebov Bali Sculptures (APIO15_sculpture) C++17
컴파일 오류
0 ms 0 KB
#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
#define ll long long
#define pb push_back
using namespace std;
 
ll dp[2001];
int n,a,b,y[2001];
ll inf = (1LL<<57);
bool f()
{
	for(int i=0;i<=n;i++)dp[i]=inf;
	dp[0]=0;
	for(int i=0;i<n;i++){
		ll sum=0;
		for(int j=i;j<n;j++)
		{
			sum += y[j];
			if((sum|ans)==ans)dp[j + 1] = min(dp[j + 1], 1 + dp[i]);
		}
	}
	return dp[n]<=b;
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>y[i];
	ll ans = (1LL<<57)-1;
	for(int i=56;i>=0;i--){
		ans^=(1LL<<i);
		if(f)ans|=(1LL<<i);
	}
	cout<<ans<<endl;
}

Compilation message

sculpture.cpp: In function 'bool f()':
sculpture.cpp:21:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |    if((sum|ans)==ans)dp[j + 1] = min(dp[j + 1], 1 + dp[i]);
      |            ^~~
      |            abs
sculpture.cpp: In function 'int main()':
sculpture.cpp:34:6: warning: the address of 'bool f()' will never be NULL [-Waddress]
   34 |   if(f)ans|=(1LL<<i);
      |      ^