#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];
int dp[maxn][maxn];
int mask = (1LL << 40) - 1;
bool can() {
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];
if((s & mask) == s) {
dp[k][i] |= 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=39; 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:14:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
^~
sculpture.cpp:14: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;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
272 ms |
31608 KB |
Output is correct |
2 |
Correct |
263 ms |
31848 KB |
Output is correct |
3 |
Correct |
257 ms |
31904 KB |
Output is correct |
4 |
Correct |
253 ms |
31904 KB |
Output is correct |
5 |
Correct |
262 ms |
31904 KB |
Output is correct |
6 |
Correct |
255 ms |
32024 KB |
Output is correct |
7 |
Correct |
263 ms |
32024 KB |
Output is correct |
8 |
Correct |
265 ms |
32096 KB |
Output is correct |
9 |
Correct |
259 ms |
32180 KB |
Output is correct |
10 |
Correct |
261 ms |
32180 KB |
Output is correct |
11 |
Correct |
268 ms |
32180 KB |
Output is correct |
12 |
Correct |
269 ms |
32180 KB |
Output is correct |
13 |
Correct |
259 ms |
32180 KB |
Output is correct |
14 |
Correct |
274 ms |
32256 KB |
Output is correct |
15 |
Correct |
266 ms |
32260 KB |
Output is correct |
16 |
Correct |
263 ms |
32260 KB |
Output is correct |
17 |
Correct |
259 ms |
32268 KB |
Output is correct |
18 |
Correct |
266 ms |
32268 KB |
Output is correct |
19 |
Correct |
272 ms |
32276 KB |
Output is correct |
20 |
Correct |
266 ms |
32276 KB |
Output is correct |
21 |
Correct |
264 ms |
32276 KB |
Output is correct |
22 |
Correct |
273 ms |
32288 KB |
Output is correct |
23 |
Correct |
266 ms |
32292 KB |
Output is correct |
24 |
Correct |
269 ms |
32292 KB |
Output is correct |
25 |
Correct |
268 ms |
32320 KB |
Output is correct |
26 |
Correct |
284 ms |
32320 KB |
Output is correct |
27 |
Correct |
263 ms |
32320 KB |
Output is correct |
28 |
Correct |
262 ms |
32320 KB |
Output is correct |
29 |
Correct |
253 ms |
32336 KB |
Output is correct |
30 |
Correct |
258 ms |
32336 KB |
Output is correct |
31 |
Correct |
251 ms |
32336 KB |
Output is correct |
32 |
Correct |
271 ms |
32348 KB |
Output is correct |
33 |
Correct |
270 ms |
32348 KB |
Output is correct |
34 |
Correct |
260 ms |
32356 KB |
Output is correct |
35 |
Correct |
271 ms |
32356 KB |
Output is correct |
36 |
Correct |
286 ms |
32356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
267 ms |
32368 KB |
Output is correct |
2 |
Correct |
271 ms |
32368 KB |
Output is correct |
3 |
Correct |
270 ms |
32368 KB |
Output is correct |
4 |
Correct |
274 ms |
32368 KB |
Output is correct |
5 |
Correct |
267 ms |
32368 KB |
Output is correct |
6 |
Correct |
273 ms |
32388 KB |
Output is correct |
7 |
Correct |
271 ms |
32388 KB |
Output is correct |
8 |
Correct |
267 ms |
32396 KB |
Output is correct |
9 |
Correct |
271 ms |
32396 KB |
Output is correct |
10 |
Correct |
268 ms |
32404 KB |
Output is correct |
11 |
Correct |
261 ms |
32404 KB |
Output is correct |
12 |
Correct |
265 ms |
32404 KB |
Output is correct |
13 |
Correct |
267 ms |
32416 KB |
Output is correct |
14 |
Correct |
261 ms |
32416 KB |
Output is correct |
15 |
Correct |
246 ms |
32416 KB |
Output is correct |
16 |
Correct |
251 ms |
32416 KB |
Output is correct |
17 |
Correct |
258 ms |
32416 KB |
Output is correct |
18 |
Correct |
254 ms |
32436 KB |
Output is correct |
19 |
Correct |
258 ms |
32436 KB |
Output is correct |
20 |
Correct |
272 ms |
32436 KB |
Output is correct |
21 |
Correct |
266 ms |
32436 KB |
Output is correct |
22 |
Correct |
263 ms |
32452 KB |
Output is correct |
23 |
Correct |
261 ms |
32452 KB |
Output is correct |
24 |
Correct |
275 ms |
32452 KB |
Output is correct |
25 |
Correct |
267 ms |
32452 KB |
Output is correct |
26 |
Correct |
268 ms |
32464 KB |
Output is correct |
27 |
Correct |
271 ms |
32472 KB |
Output is correct |
28 |
Correct |
268 ms |
32472 KB |
Output is correct |
29 |
Correct |
266 ms |
32472 KB |
Output is correct |
30 |
Correct |
271 ms |
32472 KB |
Output is correct |
31 |
Correct |
277 ms |
32472 KB |
Output is correct |
32 |
Correct |
272 ms |
32472 KB |
Output is correct |
33 |
Correct |
262 ms |
32472 KB |
Output is correct |
34 |
Correct |
259 ms |
32472 KB |
Output is correct |
35 |
Correct |
264 ms |
32508 KB |
Output is correct |
36 |
Correct |
262 ms |
32508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
271 ms |
32516 KB |
Output is correct |
2 |
Correct |
270 ms |
32516 KB |
Output is correct |
3 |
Correct |
268 ms |
32516 KB |
Output is correct |
4 |
Correct |
266 ms |
32516 KB |
Output is correct |
5 |
Correct |
270 ms |
32532 KB |
Output is correct |
6 |
Correct |
262 ms |
32536 KB |
Output is correct |
7 |
Correct |
266 ms |
32536 KB |
Output is correct |
8 |
Correct |
257 ms |
32548 KB |
Output is correct |
9 |
Correct |
244 ms |
32584 KB |
Output is correct |
10 |
Correct |
261 ms |
32584 KB |
Output is correct |
11 |
Correct |
260 ms |
32584 KB |
Output is correct |
12 |
Correct |
275 ms |
32596 KB |
Output is correct |
13 |
Correct |
285 ms |
32596 KB |
Output is correct |
14 |
Correct |
270 ms |
32596 KB |
Output is correct |
15 |
Correct |
282 ms |
32596 KB |
Output is correct |
16 |
Correct |
326 ms |
32596 KB |
Output is correct |
17 |
Correct |
314 ms |
32616 KB |
Output is correct |
18 |
Correct |
305 ms |
32620 KB |
Output is correct |
19 |
Correct |
320 ms |
32624 KB |
Output is correct |
20 |
Correct |
325 ms |
32624 KB |
Output is correct |
21 |
Correct |
341 ms |
32624 KB |
Output is correct |
22 |
Correct |
298 ms |
32636 KB |
Output is correct |
23 |
Correct |
303 ms |
32636 KB |
Output is correct |
24 |
Correct |
282 ms |
32636 KB |
Output is correct |
25 |
Correct |
298 ms |
32648 KB |
Output is correct |
26 |
Correct |
311 ms |
32648 KB |
Output is correct |
27 |
Correct |
345 ms |
32656 KB |
Output is correct |
28 |
Correct |
326 ms |
32656 KB |
Output is correct |
29 |
Correct |
352 ms |
32664 KB |
Output is correct |
30 |
Correct |
337 ms |
32668 KB |
Output is correct |
31 |
Correct |
322 ms |
32668 KB |
Output is correct |
32 |
Correct |
321 ms |
32680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
268 ms |
32680 KB |
Output is correct |
2 |
Correct |
276 ms |
32680 KB |
Output is correct |
3 |
Correct |
277 ms |
32680 KB |
Output is correct |
4 |
Correct |
265 ms |
32680 KB |
Output is correct |
5 |
Correct |
296 ms |
32680 KB |
Output is correct |
6 |
Correct |
272 ms |
32704 KB |
Output is correct |
7 |
Correct |
281 ms |
32704 KB |
Output is correct |
8 |
Correct |
276 ms |
32716 KB |
Output is correct |
9 |
Correct |
268 ms |
32748 KB |
Output is correct |
10 |
Correct |
269 ms |
32748 KB |
Output is correct |
11 |
Correct |
268 ms |
32756 KB |
Output is correct |
12 |
Correct |
274 ms |
32756 KB |
Output is correct |
13 |
Correct |
279 ms |
32756 KB |
Output is correct |
14 |
Correct |
277 ms |
32756 KB |
Output is correct |
15 |
Correct |
270 ms |
32760 KB |
Output is correct |
16 |
Correct |
267 ms |
32760 KB |
Output is correct |
17 |
Correct |
276 ms |
32760 KB |
Output is correct |
18 |
Correct |
274 ms |
32784 KB |
Output is correct |
19 |
Correct |
277 ms |
32784 KB |
Output is correct |
20 |
Correct |
270 ms |
32784 KB |
Output is correct |
21 |
Correct |
259 ms |
32800 KB |
Output is correct |
22 |
Correct |
256 ms |
32800 KB |
Output is correct |
23 |
Correct |
260 ms |
32800 KB |
Output is correct |
24 |
Correct |
262 ms |
32812 KB |
Output is correct |
25 |
Correct |
266 ms |
32816 KB |
Output is correct |
26 |
Correct |
259 ms |
32816 KB |
Output is correct |
27 |
Correct |
260 ms |
32824 KB |
Output is correct |
28 |
Correct |
301 ms |
32824 KB |
Output is correct |
29 |
Correct |
300 ms |
32824 KB |
Output is correct |
30 |
Correct |
289 ms |
32840 KB |
Output is correct |
31 |
Correct |
264 ms |
32840 KB |
Output is correct |
32 |
Correct |
267 ms |
32840 KB |
Output is correct |
33 |
Correct |
264 ms |
32852 KB |
Output is correct |
34 |
Correct |
271 ms |
32856 KB |
Output is correct |
35 |
Correct |
263 ms |
32856 KB |
Output is correct |
36 |
Correct |
270 ms |
32856 KB |
Output is correct |
37 |
Correct |
267 ms |
32868 KB |
Output is correct |
38 |
Correct |
262 ms |
32872 KB |
Output is correct |
39 |
Correct |
263 ms |
32872 KB |
Output is correct |
40 |
Correct |
265 ms |
32880 KB |
Output is correct |
41 |
Correct |
274 ms |
32884 KB |
Output is correct |
42 |
Correct |
273 ms |
32888 KB |
Output is correct |
43 |
Correct |
270 ms |
32892 KB |
Output is correct |
44 |
Correct |
282 ms |
32892 KB |
Output is correct |
45 |
Correct |
266 ms |
32892 KB |
Output is correct |
46 |
Correct |
280 ms |
32904 KB |
Output is correct |
47 |
Correct |
274 ms |
32904 KB |
Output is correct |
48 |
Correct |
287 ms |
32924 KB |
Output is correct |
49 |
Correct |
293 ms |
32952 KB |
Output is correct |
50 |
Correct |
302 ms |
32952 KB |
Output is correct |
51 |
Correct |
310 ms |
32992 KB |
Output is correct |
52 |
Correct |
316 ms |
32992 KB |
Output is correct |
53 |
Correct |
315 ms |
32992 KB |
Output is correct |
54 |
Correct |
307 ms |
32992 KB |
Output is correct |
55 |
Correct |
318 ms |
33016 KB |
Output is correct |
56 |
Correct |
259 ms |
33016 KB |
Output is correct |
57 |
Correct |
280 ms |
33016 KB |
Output is correct |
58 |
Correct |
295 ms |
33016 KB |
Output is correct |
59 |
Correct |
320 ms |
33024 KB |
Output is correct |
60 |
Correct |
304 ms |
33024 KB |
Output is correct |
61 |
Correct |
310 ms |
33024 KB |
Output is correct |
62 |
Correct |
300 ms |
33024 KB |
Output is correct |
63 |
Correct |
299 ms |
33040 KB |
Output is correct |
64 |
Correct |
315 ms |
33040 KB |
Output is correct |
65 |
Correct |
269 ms |
33048 KB |
Output is correct |
66 |
Correct |
277 ms |
33052 KB |
Output is correct |
67 |
Correct |
290 ms |
33052 KB |
Output is correct |
68 |
Correct |
296 ms |
33052 KB |
Output is correct |
69 |
Correct |
306 ms |
33064 KB |
Output is correct |
70 |
Correct |
304 ms |
33064 KB |
Output is correct |
71 |
Correct |
311 ms |
33064 KB |
Output is correct |
72 |
Correct |
305 ms |
33064 KB |
Output is correct |
73 |
Correct |
299 ms |
33080 KB |
Output is correct |
74 |
Correct |
315 ms |
33084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
268 ms |
33084 KB |
Output is correct |
2 |
Correct |
273 ms |
33084 KB |
Output is correct |
3 |
Correct |
272 ms |
33096 KB |
Output is correct |
4 |
Correct |
266 ms |
33100 KB |
Output is correct |
5 |
Correct |
259 ms |
33104 KB |
Output is correct |
6 |
Correct |
264 ms |
33104 KB |
Output is correct |
7 |
Correct |
270 ms |
33104 KB |
Output is correct |
8 |
Correct |
268 ms |
33104 KB |
Output is correct |
9 |
Correct |
260 ms |
33124 KB |
Output is correct |
10 |
Correct |
277 ms |
33124 KB |
Output is correct |
11 |
Correct |
265 ms |
33124 KB |
Output is correct |
12 |
Correct |
261 ms |
33132 KB |
Output is correct |
13 |
Correct |
269 ms |
33140 KB |
Output is correct |
14 |
Correct |
269 ms |
33144 KB |
Output is correct |
15 |
Correct |
272 ms |
33144 KB |
Output is correct |
16 |
Correct |
267 ms |
33144 KB |
Output is correct |
17 |
Correct |
269 ms |
33144 KB |
Output is correct |
18 |
Correct |
272 ms |
33160 KB |
Output is correct |
19 |
Correct |
269 ms |
33160 KB |
Output is correct |
20 |
Correct |
271 ms |
33160 KB |
Output is correct |
21 |
Correct |
273 ms |
33172 KB |
Output is correct |
22 |
Correct |
270 ms |
33172 KB |
Output is correct |
23 |
Correct |
265 ms |
33180 KB |
Output is correct |
24 |
Correct |
264 ms |
33184 KB |
Output is correct |
25 |
Correct |
270 ms |
33184 KB |
Output is correct |
26 |
Correct |
273 ms |
33192 KB |
Output is correct |
27 |
Correct |
265 ms |
33192 KB |
Output is correct |
28 |
Correct |
267 ms |
33192 KB |
Output is correct |
29 |
Correct |
277 ms |
33208 KB |
Output is correct |
30 |
Correct |
284 ms |
33208 KB |
Output is correct |
31 |
Correct |
281 ms |
33208 KB |
Output is correct |
32 |
Correct |
280 ms |
33216 KB |
Output is correct |
33 |
Correct |
269 ms |
33224 KB |
Output is correct |
34 |
Correct |
272 ms |
33224 KB |
Output is correct |
35 |
Correct |
287 ms |
33260 KB |
Output is correct |
36 |
Correct |
295 ms |
33260 KB |
Output is correct |
37 |
Correct |
303 ms |
33260 KB |
Output is correct |
38 |
Correct |
325 ms |
33308 KB |
Output is correct |
39 |
Correct |
315 ms |
33312 KB |
Output is correct |
40 |
Correct |
317 ms |
33316 KB |
Output is correct |
41 |
Correct |
321 ms |
33316 KB |
Output is correct |
42 |
Correct |
310 ms |
33316 KB |
Output is correct |
43 |
Correct |
274 ms |
33316 KB |
Output is correct |
44 |
Correct |
283 ms |
33336 KB |
Output is correct |
45 |
Correct |
296 ms |
33336 KB |
Output is correct |
46 |
Correct |
298 ms |
33336 KB |
Output is correct |
47 |
Correct |
306 ms |
33348 KB |
Output is correct |
48 |
Correct |
300 ms |
33348 KB |
Output is correct |
49 |
Correct |
309 ms |
33348 KB |
Output is correct |
50 |
Correct |
299 ms |
33356 KB |
Output is correct |
51 |
Correct |
296 ms |
33356 KB |
Output is correct |
52 |
Execution timed out |
1084 ms |
33356 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |