#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'
#define int long long
inline int myrand(int l, int r) {
int ret = rand(); ret <<= 15; ret ^= rand();
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
return os<<"(" <<p.first<<", "<<p.second<<")"; }
typedef pair<int, int> ii;
template<typename T> using min_pq =
priority_queue<T, vector<T>, greater<T> >;
//int dx[] = {-1, +0, +1, +0};
//int dy[] = {+0, +1, +0, -1};
const int maxn = 2002;
int n, A, B;
int a[maxn];
bool dp[maxn][maxn];
int mask = (1LL << 45) - 1;
bool fek() {
int temp[maxn];
temp[0] = 0;
for(int i=1; i<=n; i++) {
temp[i] = 987654321;
int s = 0;
for(int j=i; j>=1; j--) {
s += a[j];
if((s & mask) == s) {
temp[i] = min(temp[i], temp[j-1] + 1);
}
}
} return temp[n] <= B;
}
bool can() {
if(A == 1) return fek();
MEMSET(dp, 0);
dp[0][0] = 1;
for(int k=1; k<=n; k++) {
for(int i=1; i<=n; i++) {
int s = 0;
for(int j=i-1; j>=0; j--) {
s += a[j+1];
dp[k][i] |= ((s & mask) == s and dp[k-1][j]);
}
}
}
bool ret = false;
for(int i=A; i<=B; i++) {
ret |= dp[i][n];
} return ret;
}
int32_t main () {
//freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
cin>>n>>A>>B;
for(int i=1; i<=n; i++) {
cin>>a[i];
}
for(int i=44; i>=0; i--) {
mask ^= (1LL << i);
if(!can()) mask ^= (1LL << i);
}
cout << mask << endl;
return 0;
}
Compilation message
sculpture.cpp: In function 'long long int myrand(long long int, long long int)':
sculpture.cpp:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
^~
sculpture.cpp:17:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
2 ms |
448 KB |
Output is correct |
5 |
Correct |
2 ms |
448 KB |
Output is correct |
6 |
Correct |
2 ms |
448 KB |
Output is correct |
7 |
Correct |
2 ms |
448 KB |
Output is correct |
8 |
Correct |
2 ms |
508 KB |
Output is correct |
9 |
Correct |
2 ms |
508 KB |
Output is correct |
10 |
Correct |
2 ms |
584 KB |
Output is correct |
11 |
Correct |
2 ms |
616 KB |
Output is correct |
12 |
Correct |
2 ms |
616 KB |
Output is correct |
13 |
Correct |
2 ms |
620 KB |
Output is correct |
14 |
Correct |
14 ms |
4476 KB |
Output is correct |
15 |
Correct |
14 ms |
4532 KB |
Output is correct |
16 |
Correct |
16 ms |
4532 KB |
Output is correct |
17 |
Correct |
14 ms |
4532 KB |
Output is correct |
18 |
Correct |
16 ms |
4532 KB |
Output is correct |
19 |
Correct |
14 ms |
4532 KB |
Output is correct |
20 |
Correct |
16 ms |
4532 KB |
Output is correct |
21 |
Correct |
14 ms |
4532 KB |
Output is correct |
22 |
Correct |
15 ms |
4532 KB |
Output is correct |
23 |
Correct |
16 ms |
4648 KB |
Output is correct |
24 |
Correct |
15 ms |
4648 KB |
Output is correct |
25 |
Correct |
16 ms |
4648 KB |
Output is correct |
26 |
Correct |
16 ms |
4648 KB |
Output is correct |
27 |
Correct |
2 ms |
4648 KB |
Output is correct |
28 |
Correct |
2 ms |
4648 KB |
Output is correct |
29 |
Correct |
2 ms |
4648 KB |
Output is correct |
30 |
Correct |
2 ms |
4648 KB |
Output is correct |
31 |
Correct |
2 ms |
4648 KB |
Output is correct |
32 |
Correct |
2 ms |
4648 KB |
Output is correct |
33 |
Correct |
2 ms |
4648 KB |
Output is correct |
34 |
Correct |
2 ms |
4648 KB |
Output is correct |
35 |
Correct |
2 ms |
4648 KB |
Output is correct |
36 |
Correct |
2 ms |
4648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4648 KB |
Output is correct |
2 |
Correct |
2 ms |
4648 KB |
Output is correct |
3 |
Correct |
2 ms |
4648 KB |
Output is correct |
4 |
Correct |
2 ms |
4648 KB |
Output is correct |
5 |
Correct |
2 ms |
4648 KB |
Output is correct |
6 |
Correct |
2 ms |
4648 KB |
Output is correct |
7 |
Correct |
2 ms |
4648 KB |
Output is correct |
8 |
Correct |
2 ms |
4648 KB |
Output is correct |
9 |
Correct |
2 ms |
4648 KB |
Output is correct |
10 |
Correct |
2 ms |
4648 KB |
Output is correct |
11 |
Correct |
2 ms |
4648 KB |
Output is correct |
12 |
Correct |
2 ms |
4648 KB |
Output is correct |
13 |
Correct |
2 ms |
4648 KB |
Output is correct |
14 |
Correct |
14 ms |
4648 KB |
Output is correct |
15 |
Correct |
13 ms |
4648 KB |
Output is correct |
16 |
Correct |
16 ms |
4648 KB |
Output is correct |
17 |
Correct |
14 ms |
4648 KB |
Output is correct |
18 |
Correct |
15 ms |
4648 KB |
Output is correct |
19 |
Correct |
15 ms |
4648 KB |
Output is correct |
20 |
Correct |
14 ms |
4648 KB |
Output is correct |
21 |
Correct |
14 ms |
4648 KB |
Output is correct |
22 |
Correct |
14 ms |
4648 KB |
Output is correct |
23 |
Correct |
15 ms |
4648 KB |
Output is correct |
24 |
Correct |
14 ms |
4648 KB |
Output is correct |
25 |
Correct |
15 ms |
4648 KB |
Output is correct |
26 |
Correct |
17 ms |
4648 KB |
Output is correct |
27 |
Correct |
2 ms |
4648 KB |
Output is correct |
28 |
Correct |
2 ms |
4648 KB |
Output is correct |
29 |
Correct |
2 ms |
4648 KB |
Output is correct |
30 |
Correct |
2 ms |
4648 KB |
Output is correct |
31 |
Correct |
2 ms |
4648 KB |
Output is correct |
32 |
Correct |
2 ms |
4648 KB |
Output is correct |
33 |
Correct |
2 ms |
4648 KB |
Output is correct |
34 |
Correct |
2 ms |
4648 KB |
Output is correct |
35 |
Correct |
2 ms |
4648 KB |
Output is correct |
36 |
Correct |
2 ms |
4648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4648 KB |
Output is correct |
2 |
Correct |
2 ms |
4648 KB |
Output is correct |
3 |
Correct |
2 ms |
4648 KB |
Output is correct |
4 |
Correct |
2 ms |
4648 KB |
Output is correct |
5 |
Correct |
2 ms |
4648 KB |
Output is correct |
6 |
Correct |
2 ms |
4648 KB |
Output is correct |
7 |
Correct |
2 ms |
4648 KB |
Output is correct |
8 |
Correct |
2 ms |
4648 KB |
Output is correct |
9 |
Correct |
2 ms |
4648 KB |
Output is correct |
10 |
Correct |
2 ms |
4648 KB |
Output is correct |
11 |
Correct |
2 ms |
4648 KB |
Output is correct |
12 |
Correct |
2 ms |
4648 KB |
Output is correct |
13 |
Correct |
2 ms |
4648 KB |
Output is correct |
14 |
Correct |
2 ms |
4648 KB |
Output is correct |
15 |
Correct |
2 ms |
4648 KB |
Output is correct |
16 |
Correct |
2 ms |
4648 KB |
Output is correct |
17 |
Correct |
2 ms |
4648 KB |
Output is correct |
18 |
Correct |
2 ms |
4648 KB |
Output is correct |
19 |
Correct |
2 ms |
4648 KB |
Output is correct |
20 |
Correct |
2 ms |
4648 KB |
Output is correct |
21 |
Correct |
2 ms |
4648 KB |
Output is correct |
22 |
Correct |
3 ms |
4648 KB |
Output is correct |
23 |
Correct |
2 ms |
4648 KB |
Output is correct |
24 |
Correct |
2 ms |
4648 KB |
Output is correct |
25 |
Correct |
3 ms |
4648 KB |
Output is correct |
26 |
Correct |
2 ms |
4648 KB |
Output is correct |
27 |
Correct |
3 ms |
4648 KB |
Output is correct |
28 |
Correct |
3 ms |
4648 KB |
Output is correct |
29 |
Correct |
3 ms |
4648 KB |
Output is correct |
30 |
Correct |
3 ms |
4648 KB |
Output is correct |
31 |
Correct |
3 ms |
4648 KB |
Output is correct |
32 |
Correct |
3 ms |
4648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4648 KB |
Output is correct |
2 |
Correct |
2 ms |
4648 KB |
Output is correct |
3 |
Correct |
2 ms |
4648 KB |
Output is correct |
4 |
Correct |
2 ms |
4648 KB |
Output is correct |
5 |
Correct |
2 ms |
4648 KB |
Output is correct |
6 |
Correct |
2 ms |
4648 KB |
Output is correct |
7 |
Correct |
2 ms |
4648 KB |
Output is correct |
8 |
Correct |
3 ms |
4648 KB |
Output is correct |
9 |
Correct |
2 ms |
4648 KB |
Output is correct |
10 |
Correct |
2 ms |
4648 KB |
Output is correct |
11 |
Correct |
2 ms |
4648 KB |
Output is correct |
12 |
Correct |
2 ms |
4648 KB |
Output is correct |
13 |
Correct |
2 ms |
4648 KB |
Output is correct |
14 |
Correct |
17 ms |
4648 KB |
Output is correct |
15 |
Correct |
15 ms |
4648 KB |
Output is correct |
16 |
Correct |
15 ms |
4648 KB |
Output is correct |
17 |
Correct |
14 ms |
4648 KB |
Output is correct |
18 |
Correct |
16 ms |
4648 KB |
Output is correct |
19 |
Correct |
17 ms |
4648 KB |
Output is correct |
20 |
Correct |
18 ms |
4648 KB |
Output is correct |
21 |
Correct |
14 ms |
4648 KB |
Output is correct |
22 |
Correct |
14 ms |
4648 KB |
Output is correct |
23 |
Correct |
17 ms |
4648 KB |
Output is correct |
24 |
Correct |
18 ms |
4648 KB |
Output is correct |
25 |
Correct |
18 ms |
4648 KB |
Output is correct |
26 |
Correct |
17 ms |
4648 KB |
Output is correct |
27 |
Correct |
2 ms |
4648 KB |
Output is correct |
28 |
Correct |
2 ms |
4648 KB |
Output is correct |
29 |
Correct |
2 ms |
4648 KB |
Output is correct |
30 |
Correct |
2 ms |
4648 KB |
Output is correct |
31 |
Correct |
3 ms |
4648 KB |
Output is correct |
32 |
Correct |
2 ms |
4648 KB |
Output is correct |
33 |
Correct |
2 ms |
4648 KB |
Output is correct |
34 |
Correct |
2 ms |
4648 KB |
Output is correct |
35 |
Correct |
2 ms |
4648 KB |
Output is correct |
36 |
Correct |
2 ms |
4648 KB |
Output is correct |
37 |
Correct |
2 ms |
4648 KB |
Output is correct |
38 |
Correct |
2 ms |
4648 KB |
Output is correct |
39 |
Correct |
3 ms |
4648 KB |
Output is correct |
40 |
Correct |
2 ms |
4648 KB |
Output is correct |
41 |
Correct |
2 ms |
4648 KB |
Output is correct |
42 |
Correct |
2 ms |
4648 KB |
Output is correct |
43 |
Correct |
2 ms |
4648 KB |
Output is correct |
44 |
Correct |
2 ms |
4648 KB |
Output is correct |
45 |
Correct |
2 ms |
4648 KB |
Output is correct |
46 |
Correct |
2 ms |
4648 KB |
Output is correct |
47 |
Correct |
2 ms |
4648 KB |
Output is correct |
48 |
Correct |
2 ms |
4648 KB |
Output is correct |
49 |
Correct |
2 ms |
4648 KB |
Output is correct |
50 |
Correct |
2 ms |
4648 KB |
Output is correct |
51 |
Correct |
2 ms |
4648 KB |
Output is correct |
52 |
Correct |
3 ms |
4648 KB |
Output is correct |
53 |
Correct |
3 ms |
4648 KB |
Output is correct |
54 |
Correct |
2 ms |
4648 KB |
Output is correct |
55 |
Correct |
3 ms |
4648 KB |
Output is correct |
56 |
Correct |
2 ms |
4648 KB |
Output is correct |
57 |
Correct |
2 ms |
4648 KB |
Output is correct |
58 |
Correct |
2 ms |
4648 KB |
Output is correct |
59 |
Correct |
2 ms |
4648 KB |
Output is correct |
60 |
Correct |
3 ms |
4648 KB |
Output is correct |
61 |
Correct |
3 ms |
4648 KB |
Output is correct |
62 |
Correct |
2 ms |
4648 KB |
Output is correct |
63 |
Correct |
3 ms |
4648 KB |
Output is correct |
64 |
Correct |
41 ms |
4648 KB |
Output is correct |
65 |
Correct |
19 ms |
4648 KB |
Output is correct |
66 |
Correct |
25 ms |
4648 KB |
Output is correct |
67 |
Correct |
26 ms |
4648 KB |
Output is correct |
68 |
Correct |
34 ms |
4648 KB |
Output is correct |
69 |
Correct |
42 ms |
4648 KB |
Output is correct |
70 |
Correct |
37 ms |
4648 KB |
Output is correct |
71 |
Correct |
40 ms |
4648 KB |
Output is correct |
72 |
Correct |
60 ms |
4648 KB |
Output is correct |
73 |
Correct |
56 ms |
4648 KB |
Output is correct |
74 |
Correct |
41 ms |
4648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4648 KB |
Output is correct |
2 |
Correct |
2 ms |
4648 KB |
Output is correct |
3 |
Correct |
2 ms |
4648 KB |
Output is correct |
4 |
Correct |
2 ms |
4648 KB |
Output is correct |
5 |
Correct |
2 ms |
4648 KB |
Output is correct |
6 |
Correct |
2 ms |
4648 KB |
Output is correct |
7 |
Correct |
2 ms |
4648 KB |
Output is correct |
8 |
Correct |
2 ms |
4648 KB |
Output is correct |
9 |
Correct |
2 ms |
4648 KB |
Output is correct |
10 |
Correct |
2 ms |
4648 KB |
Output is correct |
11 |
Correct |
2 ms |
4648 KB |
Output is correct |
12 |
Correct |
2 ms |
4648 KB |
Output is correct |
13 |
Correct |
2 ms |
4648 KB |
Output is correct |
14 |
Correct |
2 ms |
4648 KB |
Output is correct |
15 |
Correct |
2 ms |
4648 KB |
Output is correct |
16 |
Correct |
2 ms |
4648 KB |
Output is correct |
17 |
Correct |
2 ms |
4648 KB |
Output is correct |
18 |
Correct |
2 ms |
4648 KB |
Output is correct |
19 |
Correct |
2 ms |
4648 KB |
Output is correct |
20 |
Correct |
2 ms |
4648 KB |
Output is correct |
21 |
Correct |
2 ms |
4648 KB |
Output is correct |
22 |
Correct |
2 ms |
4648 KB |
Output is correct |
23 |
Correct |
2 ms |
4648 KB |
Output is correct |
24 |
Correct |
2 ms |
4648 KB |
Output is correct |
25 |
Correct |
2 ms |
4648 KB |
Output is correct |
26 |
Correct |
2 ms |
4648 KB |
Output is correct |
27 |
Correct |
2 ms |
4648 KB |
Output is correct |
28 |
Correct |
2 ms |
4648 KB |
Output is correct |
29 |
Correct |
2 ms |
4648 KB |
Output is correct |
30 |
Correct |
2 ms |
4648 KB |
Output is correct |
31 |
Correct |
2 ms |
4648 KB |
Output is correct |
32 |
Correct |
2 ms |
4648 KB |
Output is correct |
33 |
Correct |
2 ms |
4648 KB |
Output is correct |
34 |
Correct |
2 ms |
4648 KB |
Output is correct |
35 |
Correct |
3 ms |
4648 KB |
Output is correct |
36 |
Correct |
3 ms |
4648 KB |
Output is correct |
37 |
Correct |
2 ms |
4648 KB |
Output is correct |
38 |
Correct |
3 ms |
4648 KB |
Output is correct |
39 |
Correct |
3 ms |
4648 KB |
Output is correct |
40 |
Correct |
3 ms |
4648 KB |
Output is correct |
41 |
Correct |
3 ms |
4648 KB |
Output is correct |
42 |
Correct |
3 ms |
4648 KB |
Output is correct |
43 |
Correct |
2 ms |
4648 KB |
Output is correct |
44 |
Correct |
2 ms |
4648 KB |
Output is correct |
45 |
Correct |
2 ms |
4648 KB |
Output is correct |
46 |
Correct |
2 ms |
4648 KB |
Output is correct |
47 |
Correct |
3 ms |
4648 KB |
Output is correct |
48 |
Correct |
2 ms |
4648 KB |
Output is correct |
49 |
Correct |
2 ms |
4648 KB |
Output is correct |
50 |
Correct |
3 ms |
4648 KB |
Output is correct |
51 |
Correct |
2 ms |
4648 KB |
Output is correct |
52 |
Correct |
12 ms |
4648 KB |
Output is correct |
53 |
Correct |
17 ms |
4648 KB |
Output is correct |
54 |
Correct |
32 ms |
4648 KB |
Output is correct |
55 |
Correct |
38 ms |
4648 KB |
Output is correct |
56 |
Correct |
101 ms |
4648 KB |
Output is correct |
57 |
Correct |
106 ms |
4648 KB |
Output is correct |
58 |
Correct |
113 ms |
4648 KB |
Output is correct |
59 |
Correct |
102 ms |
4648 KB |
Output is correct |
60 |
Correct |
104 ms |
4648 KB |
Output is correct |
61 |
Correct |
3 ms |
4648 KB |
Output is correct |
62 |
Correct |
27 ms |
4648 KB |
Output is correct |
63 |
Correct |
35 ms |
4648 KB |
Output is correct |
64 |
Correct |
29 ms |
4648 KB |
Output is correct |
65 |
Correct |
63 ms |
4648 KB |
Output is correct |
66 |
Correct |
90 ms |
4648 KB |
Output is correct |
67 |
Correct |
106 ms |
4648 KB |
Output is correct |
68 |
Correct |
123 ms |
4648 KB |
Output is correct |
69 |
Correct |
102 ms |
4648 KB |
Output is correct |