Submission #463886

# Submission time Handle Problem Language Result Execution time Memory
463886 2021-08-12T01:02:29 Z Hamed5001 Bali Sculptures (APIO15_sculpture) C++14
37 / 100
126 ms 16208 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int mxN = 2e3+10;
int dp1[mxN][mxN], dp2[mxN];
int N, A, B;
int Y[mxN];
ll msk, ans;

int fun2(int idx, int grp) {
	if (grp > B)
		return 0;
	if (idx == N)
		return (A <= grp && grp <= B);

	int &ret = dp1[idx][grp];
	if (~ret) return ret;

	ret = 0;
	ll sum = 0;
	for (int i = idx; i < N; ++i) {
		sum += Y[i];
		if (!(sum & msk))
			ret |= fun2(i+1, grp+1);
	}

	return ret;
}

bool check2() {
	memset(dp1, -1, sizeof dp1);
	return fun2(0, 0);
}

// void solve1() {
// 	for (int bit = 50; bit >= 0; --bit) {
// 		msk |= (1 << bit);
// 		if (!check1())
// 			msk ^= (1 << bit), ans |= (1 << bit);
// 	}
// }

void solve2() {
	for (int bit = 50; bit >= 0; --bit) {
		msk |= (1 << bit);
		if (!check2())
			msk ^= (1 << bit), ans |= (1 << bit);
	}
	cout << ans << endl;
}

void solve() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; ++i)
		cin >> Y[i];
	// if (A == 1) {
	// 	solve1();
	// }
	// else {
		solve2();
	// }
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 103 ms 16108 KB Output is correct
2 Correct 104 ms 16116 KB Output is correct
3 Correct 106 ms 16124 KB Output is correct
4 Correct 109 ms 16052 KB Output is correct
5 Correct 106 ms 16112 KB Output is correct
6 Correct 101 ms 16076 KB Output is correct
7 Correct 108 ms 16196 KB Output is correct
8 Correct 104 ms 16076 KB Output is correct
9 Correct 102 ms 16128 KB Output is correct
10 Correct 106 ms 16076 KB Output is correct
11 Correct 110 ms 16112 KB Output is correct
12 Correct 104 ms 16108 KB Output is correct
13 Correct 106 ms 16076 KB Output is correct
14 Correct 106 ms 16128 KB Output is correct
15 Correct 107 ms 16076 KB Output is correct
16 Correct 104 ms 16196 KB Output is correct
17 Correct 103 ms 16076 KB Output is correct
18 Correct 103 ms 16076 KB Output is correct
19 Correct 104 ms 16120 KB Output is correct
20 Correct 105 ms 16112 KB Output is correct
21 Correct 103 ms 16076 KB Output is correct
22 Correct 105 ms 16076 KB Output is correct
23 Correct 106 ms 16112 KB Output is correct
24 Correct 102 ms 16116 KB Output is correct
25 Correct 105 ms 16076 KB Output is correct
26 Correct 101 ms 16076 KB Output is correct
27 Incorrect 105 ms 16112 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 104 ms 16188 KB Output is correct
2 Correct 108 ms 16116 KB Output is correct
3 Correct 104 ms 16112 KB Output is correct
4 Correct 105 ms 16108 KB Output is correct
5 Correct 105 ms 16076 KB Output is correct
6 Correct 104 ms 16076 KB Output is correct
7 Correct 104 ms 16116 KB Output is correct
8 Correct 103 ms 16108 KB Output is correct
9 Correct 105 ms 16112 KB Output is correct
10 Correct 102 ms 16076 KB Output is correct
11 Correct 102 ms 16076 KB Output is correct
12 Correct 104 ms 16120 KB Output is correct
13 Correct 102 ms 16076 KB Output is correct
14 Correct 106 ms 16108 KB Output is correct
15 Correct 103 ms 16076 KB Output is correct
16 Correct 104 ms 16076 KB Output is correct
17 Correct 104 ms 16108 KB Output is correct
18 Correct 102 ms 16108 KB Output is correct
19 Correct 104 ms 16128 KB Output is correct
20 Correct 104 ms 16076 KB Output is correct
21 Correct 102 ms 16208 KB Output is correct
22 Correct 104 ms 16076 KB Output is correct
23 Correct 107 ms 16124 KB Output is correct
24 Correct 107 ms 16108 KB Output is correct
25 Correct 105 ms 16112 KB Output is correct
26 Correct 104 ms 16112 KB Output is correct
27 Correct 105 ms 16076 KB Output is correct
28 Correct 103 ms 16116 KB Output is correct
29 Correct 103 ms 16112 KB Output is correct
30 Correct 104 ms 16108 KB Output is correct
31 Correct 106 ms 16196 KB Output is correct
32 Correct 104 ms 16076 KB Output is correct
33 Correct 105 ms 16112 KB Output is correct
34 Correct 109 ms 16196 KB Output is correct
35 Correct 107 ms 16108 KB Output is correct
36 Correct 108 ms 16076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 16076 KB Output is correct
2 Correct 108 ms 16112 KB Output is correct
3 Correct 107 ms 16024 KB Output is correct
4 Correct 106 ms 16112 KB Output is correct
5 Correct 108 ms 16076 KB Output is correct
6 Correct 110 ms 16076 KB Output is correct
7 Correct 104 ms 16120 KB Output is correct
8 Correct 104 ms 16120 KB Output is correct
9 Correct 106 ms 16032 KB Output is correct
10 Correct 102 ms 16076 KB Output is correct
11 Correct 106 ms 16108 KB Output is correct
12 Correct 103 ms 16112 KB Output is correct
13 Correct 108 ms 16112 KB Output is correct
14 Correct 107 ms 16120 KB Output is correct
15 Correct 101 ms 16076 KB Output is correct
16 Correct 105 ms 16076 KB Output is correct
17 Correct 107 ms 16028 KB Output is correct
18 Correct 106 ms 16196 KB Output is correct
19 Correct 105 ms 16076 KB Output is correct
20 Correct 103 ms 16112 KB Output is correct
21 Correct 107 ms 16116 KB Output is correct
22 Correct 107 ms 16112 KB Output is correct
23 Correct 108 ms 16124 KB Output is correct
24 Correct 113 ms 16124 KB Output is correct
25 Correct 104 ms 16076 KB Output is correct
26 Correct 108 ms 16076 KB Output is correct
27 Correct 116 ms 16076 KB Output is correct
28 Correct 126 ms 16076 KB Output is correct
29 Correct 122 ms 16116 KB Output is correct
30 Correct 105 ms 16108 KB Output is correct
31 Correct 118 ms 16076 KB Output is correct
32 Correct 121 ms 16116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 16076 KB Output is correct
2 Correct 106 ms 16076 KB Output is correct
3 Correct 104 ms 16076 KB Output is correct
4 Correct 103 ms 16204 KB Output is correct
5 Correct 105 ms 16112 KB Output is correct
6 Correct 105 ms 16076 KB Output is correct
7 Correct 104 ms 16076 KB Output is correct
8 Correct 103 ms 16076 KB Output is correct
9 Correct 104 ms 16112 KB Output is correct
10 Correct 105 ms 16108 KB Output is correct
11 Correct 107 ms 16112 KB Output is correct
12 Correct 104 ms 16076 KB Output is correct
13 Correct 103 ms 16108 KB Output is correct
14 Correct 112 ms 16076 KB Output is correct
15 Correct 103 ms 16124 KB Output is correct
16 Correct 103 ms 16076 KB Output is correct
17 Correct 105 ms 16076 KB Output is correct
18 Correct 105 ms 16076 KB Output is correct
19 Correct 104 ms 16116 KB Output is correct
20 Correct 104 ms 16204 KB Output is correct
21 Correct 104 ms 16104 KB Output is correct
22 Correct 103 ms 16076 KB Output is correct
23 Correct 105 ms 16108 KB Output is correct
24 Correct 102 ms 16112 KB Output is correct
25 Correct 104 ms 16060 KB Output is correct
26 Correct 103 ms 16140 KB Output is correct
27 Incorrect 106 ms 16076 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 108 ms 16112 KB Output is correct
2 Correct 105 ms 16076 KB Output is correct
3 Correct 102 ms 16076 KB Output is correct
4 Correct 105 ms 16076 KB Output is correct
5 Correct 102 ms 16116 KB Output is correct
6 Correct 103 ms 16076 KB Output is correct
7 Correct 106 ms 16076 KB Output is correct
8 Correct 103 ms 16196 KB Output is correct
9 Correct 106 ms 16076 KB Output is correct
10 Correct 106 ms 16076 KB Output is correct
11 Correct 105 ms 16112 KB Output is correct
12 Correct 104 ms 16112 KB Output is correct
13 Correct 104 ms 16120 KB Output is correct
14 Incorrect 104 ms 16076 KB Output isn't correct
15 Halted 0 ms 0 KB -