Submission #369290

# Submission time Handle Problem Language Result Execution time Memory
369290 2021-02-21T07:00:49 Z Bill_00 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
36 ms 640 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],dpp[N];
bool check(ll mask){
	if(a>1){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				dp[i][j]=0;
			}
		}
		dp[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=i;j++){
				for(int 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(int i=a;i<=b;i++){
			if(dp[n][i]==1) return 1;
		}
		return 0;
	}
	else{
		dpp[0]=1;
		for(int i=1;i<=n;i++){
			dpp[i]=0;
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=i;j++){
				if(dpp[j-1]==1 && ((mask)&(sum[i]-sum[j-1]))==(sum[i]-sum[j-1])){
					dpp[i]=1;
				}
			}
		}
		if(dpp[n]==1) return 1;
		else return 0;
	}
}
int main() {
	cin >> n >> a >> b;
	for(int i=1;i<=n;i++){
		cin >> x[i];
		sum[i]=sum[i-1]+x[i];
	}
	ll ans=(1LL<<62)-1;
	for(int i=61;i>=0;i--){
		if(check(ans-(1LL<<i))){
			ans-=(1LL<<i);
		}
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 640 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 36 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -