Submission #972598

# Submission time Handle Problem Language Result Execution time Memory
972598 2024-04-30T17:31:57 Z Halym2007 Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e3 + 5;
ll n, A, B, dp[N], a[N], dp1[105][105];
//bool check (ll x) {
//	for (int i = 1; i <= n; ++i) {
//		dp[i] = 1e9;
//	}
//	for (int i = 1; i <= n; ++i) {
//		ll sum = 0;
//		for (int j = i; j > 0; j--) {
//			sum += a[j];
//			if ((sum & x) == sum) {
//				dp[i] = min (dp[i], dp[j - 1] + 1);
//			}
//		}
//	}
//	return dp[n] <= B;
//}



bool check1 (ll x) {
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			dp1[i][j] = 1e9;
		}
	}
	dp1[0][0] = 0;
//	if (x == 5) {
//		cout << dp1[2][1]
//	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= i; ++j) {
			ll sum = 0;
			for (int k = i; k > 0; k--) {
				sum += a[k];
				
				if ((sum & x) == sum) {
					dp1[i][j] = min (dp1[i][j], dp1[k - 1][j - 1] + 1);
//					if (x == 5 and i == 2 and j == 1) {
//						cout << "men : " << k << " " << sum;
//						exit(0);
//					}	
				}
			}
		}
	}
//	if (x == 5) {
//		for (int i = 1; i <= n; ++i) {
//			for (int j = 1; j <= i; ++j) {
//				cout << i << " " << j << " -- >"  << dp1[i][j] << "\n";
//			}
//		}
//		exit(0);
//	}
//	return 0;
	for (int i = A; i <= B; ++i) {
		if (dp1[n][i] != 1e9) return 1;
		return 0; 
	}
}

int main () {
	// freopen ("input.txt", "r", stdin);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll x = (1LL << 42) - 1;
	for (int i = 41; i >= 0; i--) {
		x ^= (1LL << i);
//		if (A == 1 and !check(x)) {
//			x ^= (1LL << i);
//		}
//		else // a > 1 diyip 
		if (!check1(x)) {
			x ^= (1LL << i);
		}
	}
	cout << x << "\n";
}

Compilation message

sculpture.cpp: In function 'bool check1(long long int)':
sculpture.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -