Submission #241849

# Submission time Handle Problem Language Result Execution time Memory
241849 2020-06-25T23:36:40 Z syy Bali Sculptures (APIO15_sculpture) C++17
100 / 100
115 ms 4352 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, a, b, arr[2005], ans;

bool ok() { //a = 1
	ll dp[2005];
	FOR(i, 1, n+1) dp[i] = LLINF;
	dp[1] = 0;
	FOR(i, 1, n) {
		ll sum = 0;
		FOR(j, i, n) {
			sum += arr[j];
			if ((sum | ans) == ans) dp[j+1] = min(dp[j+1], dp[i] + 1);
		}
	}
	return dp[n+1] <= b;
}

bool ok2() { // a != 1
	bool dp[2005][2005];
	memset(dp, 0, sizeof dp);
	dp[1][0] = 1;
	FOR(i, 1, n) FOR(j, 0, b-1) {
		ll sum = 0;
		FOR(k, i, n) {
			sum += arr[k];
			if ((sum | ans) == ans) dp[k+1][j+1] |= dp[i][j];
		}
	}
	FOR(i, a, b) if (dp[n+1][i]) return true;
	return false;
}

int main() {
	fastio; cin >> n >> a >> b;
	FOR(i, 1, n) cin >> arr[i];
	ans = (1ll<<42)-1;
	DEC(i, 41, 0) {
		ans ^= (1ll<<i);
		if (!(a == 1 ? ok() : ok2())) ans ^= (1ll<<i);
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 11 ms 4224 KB Output is correct
15 Correct 11 ms 4224 KB Output is correct
16 Correct 12 ms 4224 KB Output is correct
17 Correct 13 ms 4224 KB Output is correct
18 Correct 12 ms 4224 KB Output is correct
19 Correct 12 ms 4224 KB Output is correct
20 Correct 12 ms 4352 KB Output is correct
21 Correct 12 ms 4224 KB Output is correct
22 Correct 12 ms 4224 KB Output is correct
23 Correct 12 ms 4224 KB Output is correct
24 Correct 12 ms 4224 KB Output is correct
25 Correct 12 ms 4224 KB Output is correct
26 Correct 12 ms 4224 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 4 ms 512 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 436 KB Output is correct
14 Correct 12 ms 4224 KB Output is correct
15 Correct 12 ms 4352 KB Output is correct
16 Correct 12 ms 4224 KB Output is correct
17 Correct 17 ms 4224 KB Output is correct
18 Correct 12 ms 4224 KB Output is correct
19 Correct 11 ms 4224 KB Output is correct
20 Correct 12 ms 4224 KB Output is correct
21 Correct 13 ms 4224 KB Output is correct
22 Correct 11 ms 4352 KB Output is correct
23 Correct 12 ms 4224 KB Output is correct
24 Correct 11 ms 4224 KB Output is correct
25 Correct 12 ms 4224 KB Output is correct
26 Correct 12 ms 4352 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 12 ms 4224 KB Output is correct
15 Correct 12 ms 4224 KB Output is correct
16 Correct 12 ms 4224 KB Output is correct
17 Correct 12 ms 4352 KB Output is correct
18 Correct 12 ms 4224 KB Output is correct
19 Correct 11 ms 4224 KB Output is correct
20 Correct 11 ms 4224 KB Output is correct
21 Correct 12 ms 4224 KB Output is correct
22 Correct 12 ms 4224 KB Output is correct
23 Correct 12 ms 4224 KB Output is correct
24 Correct 13 ms 4224 KB Output is correct
25 Correct 12 ms 4352 KB Output is correct
26 Correct 12 ms 4352 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 5 ms 384 KB Output is correct
53 Correct 5 ms 384 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 5 ms 384 KB Output is correct
56 Correct 5 ms 384 KB Output is correct
57 Correct 5 ms 384 KB Output is correct
58 Correct 5 ms 384 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 5 ms 384 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 5 ms 384 KB Output is correct
64 Correct 34 ms 4320 KB Output is correct
65 Correct 14 ms 4352 KB Output is correct
66 Correct 14 ms 4352 KB Output is correct
67 Correct 20 ms 4352 KB Output is correct
68 Correct 26 ms 4224 KB Output is correct
69 Correct 42 ms 4224 KB Output is correct
70 Correct 44 ms 4224 KB Output is correct
71 Correct 13 ms 4224 KB Output is correct
72 Correct 41 ms 4224 KB Output is correct
73 Correct 33 ms 4224 KB Output is correct
74 Correct 33 ms 4224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 6 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 13 ms 384 KB Output is correct
53 Correct 19 ms 384 KB Output is correct
54 Correct 34 ms 384 KB Output is correct
55 Correct 31 ms 384 KB Output is correct
56 Correct 111 ms 408 KB Output is correct
57 Correct 110 ms 504 KB Output is correct
58 Correct 109 ms 412 KB Output is correct
59 Correct 111 ms 384 KB Output is correct
60 Correct 115 ms 408 KB Output is correct
61 Correct 5 ms 384 KB Output is correct
62 Correct 19 ms 384 KB Output is correct
63 Correct 32 ms 384 KB Output is correct
64 Correct 31 ms 384 KB Output is correct
65 Correct 55 ms 508 KB Output is correct
66 Correct 83 ms 384 KB Output is correct
67 Correct 115 ms 512 KB Output is correct
68 Correct 114 ms 384 KB Output is correct
69 Correct 105 ms 384 KB Output is correct