#include<bits/stdc++.h>
using namespace std;
#define in ({ll x=0;int n=0,c=getchar();for(;!isdigit(c);c=getchar()) n=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})
#define ll long long
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)
#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second
#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1
#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
#define bitnum(x) __builtin_popcountll(x)
////////////////////////////////////////// NIRO
#define int ll
const int N=2005;
int n,A,B;
ll a[N];
int s[N];
int f[N][N],ff[N];
ll all;
ll SUM(int u,int v){ll res=s[v]-s[u-1];return (res&all)==0;}
main()
{
// freopen("nr.inp","r",stdin);
n=in,A=in,B=in;
FOR(i,1,n) a[i]=in;
FOR(i,1,n) s[i]=s[i-1]+a[i];
ROF(bit,1,60)
{
all=on(all,bit);
if(n<=100)
{
memset(f,0,sizeof f);
FOR(i,1,n) f[i][1]=SUM(1,i);
FOR(i,1,n) FOR(j,2,B){
FOR(k,1,i-1) if(f[k][j-1]&&SUM(k+1,i)) f[i][j]=1;
}
all=off(all,bit);
FOR(i,A,B) if(f[n][i]) all=on(all,bit);
}
else
{
ll sum=0,cnt=0;
FOR(i,1,n) ff[i]=1e14;
FOR(i,1,n) FOR(j,1,i) if(SUM(j,i)) ff[i]=min(ff[i],ff[j-1]+1);
all=off(all,bit);
if(ff[n]<=B) all=on(all,bit);
}
}
FOR(i,1,60) {if(bit(all,i)) all=off(all,i);else all=on(all,i);}
cout<<all;
}
Compilation message
sculpture.cpp:43:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
sculpture.cpp: In function 'int main()':
sculpture.cpp:64:16: warning: unused variable 'sum' [-Wunused-variable]
ll sum=0,cnt=0;
^~~
sculpture.cpp:64:22: warning: unused variable 'cnt' [-Wunused-variable]
ll sum=0,cnt=0;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
335 ms |
31848 KB |
Output is correct |
2 |
Correct |
332 ms |
31844 KB |
Output is correct |
3 |
Correct |
347 ms |
31840 KB |
Output is correct |
4 |
Correct |
320 ms |
31848 KB |
Output is correct |
5 |
Correct |
330 ms |
31844 KB |
Output is correct |
6 |
Correct |
343 ms |
31836 KB |
Output is correct |
7 |
Correct |
345 ms |
31840 KB |
Output is correct |
8 |
Correct |
320 ms |
31836 KB |
Output is correct |
9 |
Correct |
339 ms |
31864 KB |
Output is correct |
10 |
Correct |
341 ms |
31840 KB |
Output is correct |
11 |
Correct |
321 ms |
31840 KB |
Output is correct |
12 |
Correct |
336 ms |
31840 KB |
Output is correct |
13 |
Correct |
346 ms |
31848 KB |
Output is correct |
14 |
Correct |
336 ms |
31864 KB |
Output is correct |
15 |
Correct |
332 ms |
31844 KB |
Output is correct |
16 |
Correct |
332 ms |
31848 KB |
Output is correct |
17 |
Correct |
323 ms |
31736 KB |
Output is correct |
18 |
Correct |
332 ms |
31836 KB |
Output is correct |
19 |
Correct |
313 ms |
31864 KB |
Output is correct |
20 |
Correct |
335 ms |
31840 KB |
Output is correct |
21 |
Correct |
349 ms |
31864 KB |
Output is correct |
22 |
Correct |
325 ms |
31864 KB |
Output is correct |
23 |
Correct |
321 ms |
31736 KB |
Output is correct |
24 |
Correct |
318 ms |
31864 KB |
Output is correct |
25 |
Correct |
307 ms |
31740 KB |
Output is correct |
26 |
Correct |
344 ms |
31864 KB |
Output is correct |
27 |
Correct |
332 ms |
31736 KB |
Output is correct |
28 |
Correct |
320 ms |
31964 KB |
Output is correct |
29 |
Correct |
314 ms |
31864 KB |
Output is correct |
30 |
Correct |
314 ms |
31736 KB |
Output is correct |
31 |
Correct |
324 ms |
31864 KB |
Output is correct |
32 |
Correct |
327 ms |
31836 KB |
Output is correct |
33 |
Correct |
350 ms |
31736 KB |
Output is correct |
34 |
Correct |
323 ms |
31864 KB |
Output is correct |
35 |
Correct |
334 ms |
31864 KB |
Output is correct |
36 |
Correct |
304 ms |
31864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
320 ms |
31736 KB |
Output is correct |
2 |
Correct |
301 ms |
31872 KB |
Output is correct |
3 |
Correct |
303 ms |
31864 KB |
Output is correct |
4 |
Correct |
302 ms |
31736 KB |
Output is correct |
5 |
Correct |
405 ms |
31864 KB |
Output is correct |
6 |
Correct |
324 ms |
31864 KB |
Output is correct |
7 |
Correct |
327 ms |
31992 KB |
Output is correct |
8 |
Correct |
344 ms |
31836 KB |
Output is correct |
9 |
Correct |
342 ms |
31864 KB |
Output is correct |
10 |
Correct |
341 ms |
31740 KB |
Output is correct |
11 |
Correct |
338 ms |
31964 KB |
Output is correct |
12 |
Correct |
322 ms |
31964 KB |
Output is correct |
13 |
Correct |
333 ms |
31864 KB |
Output is correct |
14 |
Correct |
335 ms |
31864 KB |
Output is correct |
15 |
Correct |
355 ms |
31864 KB |
Output is correct |
16 |
Correct |
394 ms |
31792 KB |
Output is correct |
17 |
Correct |
321 ms |
31864 KB |
Output is correct |
18 |
Correct |
320 ms |
31864 KB |
Output is correct |
19 |
Correct |
319 ms |
31864 KB |
Output is correct |
20 |
Correct |
460 ms |
31864 KB |
Output is correct |
21 |
Correct |
331 ms |
31940 KB |
Output is correct |
22 |
Correct |
323 ms |
31780 KB |
Output is correct |
23 |
Correct |
318 ms |
31864 KB |
Output is correct |
24 |
Correct |
346 ms |
31864 KB |
Output is correct |
25 |
Correct |
341 ms |
31844 KB |
Output is correct |
26 |
Correct |
317 ms |
31864 KB |
Output is correct |
27 |
Correct |
302 ms |
31868 KB |
Output is correct |
28 |
Correct |
312 ms |
31864 KB |
Output is correct |
29 |
Correct |
292 ms |
31740 KB |
Output is correct |
30 |
Correct |
311 ms |
31864 KB |
Output is correct |
31 |
Correct |
295 ms |
31992 KB |
Output is correct |
32 |
Correct |
315 ms |
31864 KB |
Output is correct |
33 |
Correct |
380 ms |
31936 KB |
Output is correct |
34 |
Correct |
339 ms |
31844 KB |
Output is correct |
35 |
Correct |
330 ms |
31844 KB |
Output is correct |
36 |
Correct |
307 ms |
31864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
326 ms |
31736 KB |
Output is correct |
2 |
Correct |
312 ms |
31864 KB |
Output is correct |
3 |
Correct |
315 ms |
31736 KB |
Output is correct |
4 |
Correct |
324 ms |
31864 KB |
Output is correct |
5 |
Correct |
324 ms |
31868 KB |
Output is correct |
6 |
Correct |
281 ms |
31864 KB |
Output is correct |
7 |
Correct |
301 ms |
31736 KB |
Output is correct |
8 |
Correct |
297 ms |
31864 KB |
Output is correct |
9 |
Correct |
323 ms |
31864 KB |
Output is correct |
10 |
Correct |
319 ms |
31736 KB |
Output is correct |
11 |
Correct |
314 ms |
31864 KB |
Output is correct |
12 |
Correct |
394 ms |
31736 KB |
Output is correct |
13 |
Correct |
305 ms |
31864 KB |
Output is correct |
14 |
Correct |
313 ms |
31736 KB |
Output is correct |
15 |
Correct |
340 ms |
31964 KB |
Output is correct |
16 |
Correct |
345 ms |
31836 KB |
Output is correct |
17 |
Correct |
326 ms |
31864 KB |
Output is correct |
18 |
Correct |
345 ms |
31736 KB |
Output is correct |
19 |
Correct |
320 ms |
31964 KB |
Output is correct |
20 |
Correct |
346 ms |
31836 KB |
Output is correct |
21 |
Correct |
360 ms |
31864 KB |
Output is correct |
22 |
Correct |
329 ms |
31864 KB |
Output is correct |
23 |
Correct |
367 ms |
31836 KB |
Output is correct |
24 |
Correct |
324 ms |
31992 KB |
Output is correct |
25 |
Correct |
314 ms |
31736 KB |
Output is correct |
26 |
Correct |
347 ms |
31864 KB |
Output is correct |
27 |
Correct |
415 ms |
31944 KB |
Output is correct |
28 |
Correct |
388 ms |
31996 KB |
Output is correct |
29 |
Correct |
376 ms |
31864 KB |
Output is correct |
30 |
Correct |
382 ms |
31964 KB |
Output is correct |
31 |
Correct |
348 ms |
31736 KB |
Output is correct |
32 |
Correct |
383 ms |
31864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
339 ms |
31840 KB |
Output is correct |
2 |
Correct |
329 ms |
31864 KB |
Output is correct |
3 |
Correct |
278 ms |
31992 KB |
Output is correct |
4 |
Correct |
292 ms |
31864 KB |
Output is correct |
5 |
Correct |
285 ms |
31888 KB |
Output is correct |
6 |
Correct |
327 ms |
31992 KB |
Output is correct |
7 |
Correct |
352 ms |
31844 KB |
Output is correct |
8 |
Correct |
294 ms |
31736 KB |
Output is correct |
9 |
Correct |
358 ms |
31992 KB |
Output is correct |
10 |
Correct |
330 ms |
31864 KB |
Output is correct |
11 |
Correct |
342 ms |
31964 KB |
Output is correct |
12 |
Correct |
332 ms |
31864 KB |
Output is correct |
13 |
Correct |
331 ms |
31836 KB |
Output is correct |
14 |
Correct |
331 ms |
31840 KB |
Output is correct |
15 |
Correct |
374 ms |
31840 KB |
Output is correct |
16 |
Correct |
442 ms |
31840 KB |
Output is correct |
17 |
Correct |
292 ms |
31736 KB |
Output is correct |
18 |
Correct |
331 ms |
31840 KB |
Output is correct |
19 |
Correct |
324 ms |
31840 KB |
Output is correct |
20 |
Correct |
358 ms |
31964 KB |
Output is correct |
21 |
Correct |
313 ms |
31840 KB |
Output is correct |
22 |
Correct |
359 ms |
31836 KB |
Output is correct |
23 |
Correct |
329 ms |
31736 KB |
Output is correct |
24 |
Correct |
335 ms |
31840 KB |
Output is correct |
25 |
Correct |
320 ms |
31836 KB |
Output is correct |
26 |
Correct |
404 ms |
31736 KB |
Output is correct |
27 |
Correct |
318 ms |
31720 KB |
Output is correct |
28 |
Correct |
321 ms |
31840 KB |
Output is correct |
29 |
Correct |
327 ms |
31736 KB |
Output is correct |
30 |
Correct |
331 ms |
31836 KB |
Output is correct |
31 |
Correct |
365 ms |
31844 KB |
Output is correct |
32 |
Correct |
319 ms |
31840 KB |
Output is correct |
33 |
Correct |
311 ms |
31864 KB |
Output is correct |
34 |
Correct |
297 ms |
31864 KB |
Output is correct |
35 |
Correct |
310 ms |
31840 KB |
Output is correct |
36 |
Correct |
328 ms |
31864 KB |
Output is correct |
37 |
Correct |
337 ms |
31736 KB |
Output is correct |
38 |
Correct |
324 ms |
31864 KB |
Output is correct |
39 |
Correct |
323 ms |
31736 KB |
Output is correct |
40 |
Correct |
262 ms |
31736 KB |
Output is correct |
41 |
Correct |
364 ms |
31864 KB |
Output is correct |
42 |
Correct |
319 ms |
31864 KB |
Output is correct |
43 |
Correct |
327 ms |
31864 KB |
Output is correct |
44 |
Correct |
327 ms |
31864 KB |
Output is correct |
45 |
Correct |
308 ms |
31864 KB |
Output is correct |
46 |
Correct |
304 ms |
31864 KB |
Output is correct |
47 |
Correct |
317 ms |
31992 KB |
Output is correct |
48 |
Correct |
323 ms |
31868 KB |
Output is correct |
49 |
Correct |
333 ms |
31864 KB |
Output is correct |
50 |
Correct |
346 ms |
31864 KB |
Output is correct |
51 |
Correct |
373 ms |
31736 KB |
Output is correct |
52 |
Correct |
371 ms |
31736 KB |
Output is correct |
53 |
Correct |
320 ms |
31840 KB |
Output is correct |
54 |
Correct |
349 ms |
31868 KB |
Output is correct |
55 |
Correct |
345 ms |
31864 KB |
Output is correct |
56 |
Correct |
312 ms |
31864 KB |
Output is correct |
57 |
Correct |
319 ms |
31864 KB |
Output is correct |
58 |
Correct |
467 ms |
31736 KB |
Output is correct |
59 |
Correct |
386 ms |
31736 KB |
Output is correct |
60 |
Correct |
376 ms |
31844 KB |
Output is correct |
61 |
Correct |
318 ms |
31844 KB |
Output is correct |
62 |
Correct |
475 ms |
31864 KB |
Output is correct |
63 |
Correct |
423 ms |
31868 KB |
Output is correct |
64 |
Correct |
366 ms |
31864 KB |
Output is correct |
65 |
Correct |
304 ms |
31836 KB |
Output is correct |
66 |
Correct |
295 ms |
31864 KB |
Output is correct |
67 |
Correct |
319 ms |
31864 KB |
Output is correct |
68 |
Correct |
316 ms |
31736 KB |
Output is correct |
69 |
Correct |
363 ms |
31736 KB |
Output is correct |
70 |
Correct |
369 ms |
31936 KB |
Output is correct |
71 |
Correct |
307 ms |
31880 KB |
Output is correct |
72 |
Correct |
361 ms |
31864 KB |
Output is correct |
73 |
Correct |
352 ms |
31992 KB |
Output is correct |
74 |
Correct |
327 ms |
31864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
301 ms |
31864 KB |
Output is correct |
2 |
Correct |
302 ms |
31864 KB |
Output is correct |
3 |
Correct |
311 ms |
31992 KB |
Output is correct |
4 |
Correct |
308 ms |
31864 KB |
Output is correct |
5 |
Correct |
320 ms |
31864 KB |
Output is correct |
6 |
Correct |
369 ms |
31736 KB |
Output is correct |
7 |
Correct |
329 ms |
31864 KB |
Output is correct |
8 |
Correct |
366 ms |
31876 KB |
Output is correct |
9 |
Correct |
342 ms |
31864 KB |
Output is correct |
10 |
Correct |
329 ms |
31864 KB |
Output is correct |
11 |
Correct |
322 ms |
31736 KB |
Output is correct |
12 |
Correct |
305 ms |
31992 KB |
Output is correct |
13 |
Correct |
287 ms |
31992 KB |
Output is correct |
14 |
Correct |
320 ms |
31864 KB |
Output is correct |
15 |
Correct |
463 ms |
31864 KB |
Output is correct |
16 |
Correct |
332 ms |
31864 KB |
Output is correct |
17 |
Correct |
288 ms |
31840 KB |
Output is correct |
18 |
Correct |
351 ms |
31844 KB |
Output is correct |
19 |
Correct |
332 ms |
31864 KB |
Output is correct |
20 |
Correct |
411 ms |
31864 KB |
Output is correct |
21 |
Correct |
334 ms |
31864 KB |
Output is correct |
22 |
Correct |
343 ms |
31840 KB |
Output is correct |
23 |
Correct |
303 ms |
31840 KB |
Output is correct |
24 |
Correct |
296 ms |
31864 KB |
Output is correct |
25 |
Correct |
306 ms |
31864 KB |
Output is correct |
26 |
Correct |
338 ms |
31840 KB |
Output is correct |
27 |
Correct |
336 ms |
31844 KB |
Output is correct |
28 |
Correct |
325 ms |
31736 KB |
Output is correct |
29 |
Correct |
329 ms |
31868 KB |
Output is correct |
30 |
Correct |
330 ms |
31736 KB |
Output is correct |
31 |
Correct |
327 ms |
31736 KB |
Output is correct |
32 |
Correct |
307 ms |
31736 KB |
Output is correct |
33 |
Correct |
319 ms |
31864 KB |
Output is correct |
34 |
Correct |
336 ms |
31864 KB |
Output is correct |
35 |
Correct |
328 ms |
31976 KB |
Output is correct |
36 |
Correct |
304 ms |
31740 KB |
Output is correct |
37 |
Correct |
341 ms |
31864 KB |
Output is correct |
38 |
Correct |
353 ms |
31852 KB |
Output is correct |
39 |
Correct |
409 ms |
31992 KB |
Output is correct |
40 |
Correct |
311 ms |
31864 KB |
Output is correct |
41 |
Correct |
372 ms |
31840 KB |
Output is correct |
42 |
Correct |
322 ms |
31992 KB |
Output is correct |
43 |
Correct |
304 ms |
31836 KB |
Output is correct |
44 |
Correct |
341 ms |
31836 KB |
Output is correct |
45 |
Correct |
430 ms |
31864 KB |
Output is correct |
46 |
Correct |
379 ms |
31864 KB |
Output is correct |
47 |
Correct |
389 ms |
31736 KB |
Output is correct |
48 |
Correct |
315 ms |
31840 KB |
Output is correct |
49 |
Correct |
402 ms |
31840 KB |
Output is correct |
50 |
Correct |
387 ms |
31864 KB |
Output is correct |
51 |
Correct |
3 ms |
376 KB |
Output is correct |
52 |
Correct |
21 ms |
376 KB |
Output is correct |
53 |
Correct |
32 ms |
380 KB |
Output is correct |
54 |
Correct |
57 ms |
404 KB |
Output is correct |
55 |
Correct |
55 ms |
376 KB |
Output is correct |
56 |
Correct |
209 ms |
512 KB |
Output is correct |
57 |
Correct |
207 ms |
376 KB |
Output is correct |
58 |
Correct |
204 ms |
504 KB |
Output is correct |
59 |
Correct |
203 ms |
468 KB |
Output is correct |
60 |
Correct |
211 ms |
376 KB |
Output is correct |
61 |
Correct |
3 ms |
376 KB |
Output is correct |
62 |
Correct |
32 ms |
376 KB |
Output is correct |
63 |
Correct |
57 ms |
440 KB |
Output is correct |
64 |
Correct |
54 ms |
376 KB |
Output is correct |
65 |
Correct |
105 ms |
416 KB |
Output is correct |
66 |
Correct |
158 ms |
504 KB |
Output is correct |
67 |
Correct |
208 ms |
504 KB |
Output is correct |
68 |
Correct |
210 ms |
376 KB |
Output is correct |
69 |
Correct |
205 ms |
376 KB |
Output is correct |