#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];
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,41)
{
bitset<2005> f[N];
all=on(all,bit);
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;
}
*/
FOR(i,1,n){
FOR(k,1,i-1){
if(SUM(k+1,i)){
//f[k][j-1] -> f[i][j]
f[i]|=f[k]<<1;
}
}
}
all=off(all,bit);
FOR(i,A,B) if(f[n][i]) all=on(all,bit);
}
FOR(i,1,41) {if(bit(all,i)) all=off(all,i);else all=on(all,i);}
cout<<all;
}
Compilation message
sculpture.cpp:42:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
888 KB |
Output is correct |
2 |
Correct |
3 ms |
888 KB |
Output is correct |
3 |
Correct |
4 ms |
888 KB |
Output is correct |
4 |
Correct |
4 ms |
888 KB |
Output is correct |
5 |
Correct |
4 ms |
888 KB |
Output is correct |
6 |
Correct |
4 ms |
760 KB |
Output is correct |
7 |
Correct |
4 ms |
888 KB |
Output is correct |
8 |
Correct |
4 ms |
888 KB |
Output is correct |
9 |
Correct |
4 ms |
888 KB |
Output is correct |
10 |
Correct |
4 ms |
888 KB |
Output is correct |
11 |
Correct |
4 ms |
888 KB |
Output is correct |
12 |
Correct |
4 ms |
760 KB |
Output is correct |
13 |
Correct |
4 ms |
888 KB |
Output is correct |
14 |
Correct |
3 ms |
760 KB |
Output is correct |
15 |
Correct |
4 ms |
760 KB |
Output is correct |
16 |
Correct |
4 ms |
760 KB |
Output is correct |
17 |
Correct |
4 ms |
760 KB |
Output is correct |
18 |
Correct |
4 ms |
888 KB |
Output is correct |
19 |
Correct |
4 ms |
760 KB |
Output is correct |
20 |
Correct |
4 ms |
888 KB |
Output is correct |
21 |
Correct |
4 ms |
760 KB |
Output is correct |
22 |
Correct |
4 ms |
888 KB |
Output is correct |
23 |
Correct |
4 ms |
888 KB |
Output is correct |
24 |
Correct |
4 ms |
888 KB |
Output is correct |
25 |
Correct |
4 ms |
888 KB |
Output is correct |
26 |
Correct |
4 ms |
888 KB |
Output is correct |
27 |
Correct |
3 ms |
888 KB |
Output is correct |
28 |
Correct |
4 ms |
744 KB |
Output is correct |
29 |
Correct |
4 ms |
760 KB |
Output is correct |
30 |
Correct |
4 ms |
888 KB |
Output is correct |
31 |
Correct |
4 ms |
760 KB |
Output is correct |
32 |
Correct |
4 ms |
888 KB |
Output is correct |
33 |
Correct |
4 ms |
888 KB |
Output is correct |
34 |
Correct |
4 ms |
760 KB |
Output is correct |
35 |
Correct |
4 ms |
888 KB |
Output is correct |
36 |
Correct |
4 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
888 KB |
Output is correct |
2 |
Correct |
4 ms |
888 KB |
Output is correct |
3 |
Correct |
4 ms |
888 KB |
Output is correct |
4 |
Correct |
4 ms |
892 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
4 ms |
760 KB |
Output is correct |
7 |
Correct |
4 ms |
760 KB |
Output is correct |
8 |
Correct |
4 ms |
888 KB |
Output is correct |
9 |
Correct |
4 ms |
760 KB |
Output is correct |
10 |
Correct |
5 ms |
760 KB |
Output is correct |
11 |
Correct |
4 ms |
888 KB |
Output is correct |
12 |
Correct |
4 ms |
888 KB |
Output is correct |
13 |
Correct |
4 ms |
888 KB |
Output is correct |
14 |
Correct |
4 ms |
888 KB |
Output is correct |
15 |
Correct |
4 ms |
888 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
4 ms |
888 KB |
Output is correct |
18 |
Correct |
4 ms |
760 KB |
Output is correct |
19 |
Correct |
4 ms |
760 KB |
Output is correct |
20 |
Correct |
4 ms |
888 KB |
Output is correct |
21 |
Correct |
4 ms |
888 KB |
Output is correct |
22 |
Correct |
4 ms |
888 KB |
Output is correct |
23 |
Correct |
4 ms |
760 KB |
Output is correct |
24 |
Correct |
4 ms |
888 KB |
Output is correct |
25 |
Correct |
4 ms |
888 KB |
Output is correct |
26 |
Correct |
4 ms |
888 KB |
Output is correct |
27 |
Correct |
4 ms |
760 KB |
Output is correct |
28 |
Correct |
4 ms |
760 KB |
Output is correct |
29 |
Correct |
5 ms |
888 KB |
Output is correct |
30 |
Correct |
6 ms |
888 KB |
Output is correct |
31 |
Correct |
6 ms |
888 KB |
Output is correct |
32 |
Correct |
7 ms |
892 KB |
Output is correct |
33 |
Correct |
7 ms |
888 KB |
Output is correct |
34 |
Correct |
7 ms |
888 KB |
Output is correct |
35 |
Correct |
6 ms |
888 KB |
Output is correct |
36 |
Correct |
6 ms |
892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
888 KB |
Output is correct |
2 |
Correct |
4 ms |
760 KB |
Output is correct |
3 |
Correct |
4 ms |
888 KB |
Output is correct |
4 |
Correct |
3 ms |
888 KB |
Output is correct |
5 |
Correct |
4 ms |
888 KB |
Output is correct |
6 |
Correct |
4 ms |
888 KB |
Output is correct |
7 |
Correct |
4 ms |
760 KB |
Output is correct |
8 |
Correct |
4 ms |
888 KB |
Output is correct |
9 |
Correct |
4 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
888 KB |
Output is correct |
11 |
Correct |
4 ms |
888 KB |
Output is correct |
12 |
Correct |
4 ms |
888 KB |
Output is correct |
13 |
Correct |
4 ms |
888 KB |
Output is correct |
14 |
Correct |
4 ms |
760 KB |
Output is correct |
15 |
Correct |
4 ms |
892 KB |
Output is correct |
16 |
Correct |
5 ms |
760 KB |
Output is correct |
17 |
Correct |
6 ms |
888 KB |
Output is correct |
18 |
Correct |
7 ms |
900 KB |
Output is correct |
19 |
Correct |
7 ms |
888 KB |
Output is correct |
20 |
Correct |
7 ms |
888 KB |
Output is correct |
21 |
Correct |
7 ms |
760 KB |
Output is correct |
22 |
Correct |
7 ms |
760 KB |
Output is correct |
23 |
Correct |
6 ms |
888 KB |
Output is correct |
24 |
Correct |
6 ms |
760 KB |
Output is correct |
25 |
Correct |
8 ms |
760 KB |
Output is correct |
26 |
Correct |
10 ms |
760 KB |
Output is correct |
27 |
Correct |
13 ms |
888 KB |
Output is correct |
28 |
Correct |
15 ms |
760 KB |
Output is correct |
29 |
Correct |
14 ms |
888 KB |
Output is correct |
30 |
Correct |
15 ms |
760 KB |
Output is correct |
31 |
Correct |
15 ms |
888 KB |
Output is correct |
32 |
Correct |
15 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Output is correct |
2 |
Correct |
4 ms |
760 KB |
Output is correct |
3 |
Correct |
4 ms |
760 KB |
Output is correct |
4 |
Correct |
4 ms |
888 KB |
Output is correct |
5 |
Correct |
4 ms |
888 KB |
Output is correct |
6 |
Correct |
4 ms |
888 KB |
Output is correct |
7 |
Correct |
4 ms |
888 KB |
Output is correct |
8 |
Correct |
5 ms |
888 KB |
Output is correct |
9 |
Correct |
4 ms |
888 KB |
Output is correct |
10 |
Correct |
4 ms |
760 KB |
Output is correct |
11 |
Correct |
4 ms |
888 KB |
Output is correct |
12 |
Correct |
4 ms |
888 KB |
Output is correct |
13 |
Correct |
4 ms |
888 KB |
Output is correct |
14 |
Correct |
4 ms |
888 KB |
Output is correct |
15 |
Correct |
4 ms |
888 KB |
Output is correct |
16 |
Correct |
4 ms |
888 KB |
Output is correct |
17 |
Correct |
3 ms |
888 KB |
Output is correct |
18 |
Correct |
3 ms |
888 KB |
Output is correct |
19 |
Correct |
4 ms |
760 KB |
Output is correct |
20 |
Correct |
4 ms |
860 KB |
Output is correct |
21 |
Correct |
4 ms |
760 KB |
Output is correct |
22 |
Correct |
4 ms |
888 KB |
Output is correct |
23 |
Correct |
4 ms |
888 KB |
Output is correct |
24 |
Correct |
4 ms |
888 KB |
Output is correct |
25 |
Correct |
4 ms |
888 KB |
Output is correct |
26 |
Correct |
4 ms |
888 KB |
Output is correct |
27 |
Correct |
4 ms |
888 KB |
Output is correct |
28 |
Correct |
3 ms |
760 KB |
Output is correct |
29 |
Correct |
4 ms |
892 KB |
Output is correct |
30 |
Correct |
4 ms |
888 KB |
Output is correct |
31 |
Correct |
4 ms |
888 KB |
Output is correct |
32 |
Correct |
4 ms |
760 KB |
Output is correct |
33 |
Correct |
4 ms |
756 KB |
Output is correct |
34 |
Correct |
4 ms |
760 KB |
Output is correct |
35 |
Correct |
4 ms |
788 KB |
Output is correct |
36 |
Correct |
4 ms |
760 KB |
Output is correct |
37 |
Correct |
4 ms |
888 KB |
Output is correct |
38 |
Correct |
4 ms |
888 KB |
Output is correct |
39 |
Correct |
6 ms |
888 KB |
Output is correct |
40 |
Correct |
6 ms |
888 KB |
Output is correct |
41 |
Correct |
7 ms |
760 KB |
Output is correct |
42 |
Correct |
7 ms |
760 KB |
Output is correct |
43 |
Correct |
7 ms |
888 KB |
Output is correct |
44 |
Correct |
7 ms |
888 KB |
Output is correct |
45 |
Correct |
7 ms |
892 KB |
Output is correct |
46 |
Correct |
7 ms |
864 KB |
Output is correct |
47 |
Correct |
7 ms |
864 KB |
Output is correct |
48 |
Correct |
8 ms |
888 KB |
Output is correct |
49 |
Correct |
10 ms |
760 KB |
Output is correct |
50 |
Correct |
13 ms |
760 KB |
Output is correct |
51 |
Correct |
15 ms |
888 KB |
Output is correct |
52 |
Correct |
15 ms |
892 KB |
Output is correct |
53 |
Correct |
15 ms |
804 KB |
Output is correct |
54 |
Correct |
15 ms |
760 KB |
Output is correct |
55 |
Correct |
15 ms |
1016 KB |
Output is correct |
56 |
Correct |
4 ms |
760 KB |
Output is correct |
57 |
Correct |
6 ms |
760 KB |
Output is correct |
58 |
Correct |
6 ms |
888 KB |
Output is correct |
59 |
Correct |
6 ms |
760 KB |
Output is correct |
60 |
Correct |
6 ms |
888 KB |
Output is correct |
61 |
Correct |
6 ms |
760 KB |
Output is correct |
62 |
Correct |
8 ms |
760 KB |
Output is correct |
63 |
Correct |
8 ms |
888 KB |
Output is correct |
64 |
Correct |
14 ms |
900 KB |
Output is correct |
65 |
Correct |
5 ms |
764 KB |
Output is correct |
66 |
Correct |
5 ms |
888 KB |
Output is correct |
67 |
Correct |
5 ms |
888 KB |
Output is correct |
68 |
Correct |
6 ms |
888 KB |
Output is correct |
69 |
Correct |
6 ms |
760 KB |
Output is correct |
70 |
Correct |
6 ms |
888 KB |
Output is correct |
71 |
Correct |
7 ms |
888 KB |
Output is correct |
72 |
Correct |
8 ms |
888 KB |
Output is correct |
73 |
Correct |
8 ms |
788 KB |
Output is correct |
74 |
Correct |
8 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
888 KB |
Output is correct |
2 |
Correct |
4 ms |
760 KB |
Output is correct |
3 |
Correct |
4 ms |
788 KB |
Output is correct |
4 |
Correct |
3 ms |
760 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
4 ms |
888 KB |
Output is correct |
7 |
Correct |
4 ms |
760 KB |
Output is correct |
8 |
Correct |
4 ms |
888 KB |
Output is correct |
9 |
Correct |
4 ms |
760 KB |
Output is correct |
10 |
Correct |
4 ms |
892 KB |
Output is correct |
11 |
Correct |
4 ms |
760 KB |
Output is correct |
12 |
Correct |
4 ms |
892 KB |
Output is correct |
13 |
Correct |
4 ms |
888 KB |
Output is correct |
14 |
Correct |
3 ms |
760 KB |
Output is correct |
15 |
Correct |
4 ms |
888 KB |
Output is correct |
16 |
Correct |
4 ms |
888 KB |
Output is correct |
17 |
Correct |
4 ms |
888 KB |
Output is correct |
18 |
Correct |
4 ms |
888 KB |
Output is correct |
19 |
Correct |
4 ms |
888 KB |
Output is correct |
20 |
Correct |
4 ms |
760 KB |
Output is correct |
21 |
Correct |
4 ms |
888 KB |
Output is correct |
22 |
Correct |
4 ms |
888 KB |
Output is correct |
23 |
Correct |
4 ms |
760 KB |
Output is correct |
24 |
Correct |
4 ms |
888 KB |
Output is correct |
25 |
Correct |
4 ms |
888 KB |
Output is correct |
26 |
Correct |
5 ms |
888 KB |
Output is correct |
27 |
Correct |
6 ms |
892 KB |
Output is correct |
28 |
Correct |
6 ms |
888 KB |
Output is correct |
29 |
Correct |
6 ms |
760 KB |
Output is correct |
30 |
Correct |
7 ms |
760 KB |
Output is correct |
31 |
Correct |
7 ms |
888 KB |
Output is correct |
32 |
Correct |
7 ms |
900 KB |
Output is correct |
33 |
Correct |
7 ms |
888 KB |
Output is correct |
34 |
Correct |
7 ms |
760 KB |
Output is correct |
35 |
Correct |
9 ms |
888 KB |
Output is correct |
36 |
Correct |
11 ms |
892 KB |
Output is correct |
37 |
Correct |
17 ms |
888 KB |
Output is correct |
38 |
Correct |
15 ms |
760 KB |
Output is correct |
39 |
Correct |
15 ms |
912 KB |
Output is correct |
40 |
Correct |
15 ms |
760 KB |
Output is correct |
41 |
Correct |
15 ms |
888 KB |
Output is correct |
42 |
Correct |
15 ms |
888 KB |
Output is correct |
43 |
Correct |
4 ms |
888 KB |
Output is correct |
44 |
Correct |
6 ms |
760 KB |
Output is correct |
45 |
Correct |
6 ms |
760 KB |
Output is correct |
46 |
Correct |
6 ms |
888 KB |
Output is correct |
47 |
Correct |
6 ms |
888 KB |
Output is correct |
48 |
Correct |
6 ms |
888 KB |
Output is correct |
49 |
Correct |
8 ms |
760 KB |
Output is correct |
50 |
Correct |
8 ms |
888 KB |
Output is correct |
51 |
Correct |
7 ms |
888 KB |
Output is correct |
52 |
Correct |
64 ms |
888 KB |
Output is correct |
53 |
Correct |
94 ms |
1016 KB |
Output is correct |
54 |
Correct |
166 ms |
988 KB |
Output is correct |
55 |
Correct |
154 ms |
888 KB |
Output is correct |
56 |
Correct |
449 ms |
888 KB |
Output is correct |
57 |
Correct |
442 ms |
904 KB |
Output is correct |
58 |
Correct |
309 ms |
1016 KB |
Output is correct |
59 |
Correct |
310 ms |
1016 KB |
Output is correct |
60 |
Correct |
593 ms |
888 KB |
Output is correct |
61 |
Correct |
9 ms |
888 KB |
Output is correct |
62 |
Correct |
93 ms |
888 KB |
Output is correct |
63 |
Correct |
162 ms |
888 KB |
Output is correct |
64 |
Correct |
142 ms |
920 KB |
Output is correct |
65 |
Correct |
232 ms |
896 KB |
Output is correct |
66 |
Correct |
317 ms |
1016 KB |
Output is correct |
67 |
Correct |
438 ms |
888 KB |
Output is correct |
68 |
Correct |
433 ms |
888 KB |
Output is correct |
69 |
Correct |
378 ms |
1016 KB |
Output is correct |