Submission #36482

# Submission time Handle Problem Language Result Execution time Memory
36482 2017-12-09T13:25:36 Z UncleGrandpa925 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
0 ms 2216 KB
/*input
6 1 3
8 1 2 1 5 4
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 2005
#define bit(x,y) ((x>>y)&1LL)
#define na(x) (#x) << ":" << x
ostream& operator << (ostream &os, vector<int>&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << sp;
	return os;
}
ostream& operator << (ostream &os, pair<int, int> x) {
	cout << x.fi << sp << x.se << sp;
	return os;
}
ostream& operator << (ostream &os, vector<pair<int, int> >&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << endl;
	return os;
}

int n, A, B;
int a[N], sum[N];

int getSum(int l, int r) {
	return sum[r] - sum[l - 1];
}

namespace sub4 {
bool dp[105][105];

bool valid(int curMask, int lim) {
	return ((curMask & lim) == 0 ? 1 : 0);
}

bool check(int mask) {
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= n; i++) dp[i][1] = valid(getSum(1, i), mask);
	for (int k = 2; k <= B; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= i; j++) {
				if (dp[j - 1][k - 1] == false) continue;
				if (!valid(getSum(j, i), mask)) continue;
				dp[i][k] = true; break;
			}
		}
		if (A <= k && k <= B && dp[n][k]) return true;
	}
	return false;
}

void solve() {
	int mask = 0; int ret = 0;
	for (int i = 60; i >= 0; i--) {
		mask ^= (1LL << i);
		if (!check(mask)) mask ^= (1LL << i), ret ^= (1LL << i);
	}
	cout << ret << endl;
}

}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef in1code
	freopen("1test.inp", "r", stdin);
#endif
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i];
	if (n <= 100) {
		sub4::solve();
	}
}

Compilation message

sculpture.cpp: In function 'std::ostream& operator<<(std::ostream&, std::vector<long long int>&)':
sculpture.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < x.size(); i++) os << x[i] << sp;
                    ^
sculpture.cpp: In function 'std::ostream& operator<<(std::ostream&, std::vector<std::pair<long long int, long long int> >&)':
sculpture.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < x.size(); i++) os << x[i] << endl;
                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Incorrect 0 ms 2216 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Incorrect 0 ms 2216 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Incorrect 0 ms 2216 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Incorrect 0 ms 2216 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Incorrect 0 ms 2216 KB Output isn't correct
4 Halted 0 ms 0 KB -