#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define sz(x) (ll)(x).size()
#define all(x) x.begin(),x.end()
#define inf 1000000000000000000
ll n,a,b,ans;
vi y;
string binary(ll x){
string s = "";
while(x>0){
if (x%2) s += '1';
else s += '0';
x /= 2;
}
reverse(all(s));
return s;
}
bool solve(ll x){
//cout << binary(((1LL<<50)-1LL)^x) << endl;
if (a == 1){
vi dp; dp.assign(n+1,inf); dp[0] = 0;
rep(i,1,n+1){
ll cur = 0;
per(j,i-1,0){
cur += y[j];
//cout << cur << " " << (cur&(((1LL<<50)-1LL)^x)) << " " << j << " " << dp[j] << endl;
if ((cur&(((1LL<<50)-1LL)^x)) == 0) dp[i] = min(dp[i],dp[j]+1);
}
}
//rep(i,0,n) cout << dp[i] << " ";
//cout << endl;
//cout << x << " " << dp[n] << endl;
if (dp[n] <= b) return 1;
return 0;
} else {
vector<vi> dp;
vi _; _.assign(n+1,0);
dp.assign(n+1,_);
dp[0][0] = 1;
rep(i,1,n+1) rep(j,1,n+1){
ll cur = 0;
per(k,j-1,0){
cur += y[k];
if ((cur&(((1LL<<60)-1LL)^x)) == 0) {
if (dp[i-1][k]) dp[i][j] = 1;
}
}
}
rep(i,a,b+1) if (dp[i][n]) return 1;
return 0;
}
}
int main(){
cin >> n >> a >> b; y.assign(n,0);
rep(i,0,n) cin >> y[i];
ans = 0;
per(i,35,0) if (!solve(ans+(1LL<<i)-1LL)) ans += (1LL<<i);
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
616 KB |
Output is correct |
5 |
Correct |
3 ms |
616 KB |
Output is correct |
6 |
Correct |
2 ms |
616 KB |
Output is correct |
7 |
Correct |
3 ms |
616 KB |
Output is correct |
8 |
Correct |
3 ms |
616 KB |
Output is correct |
9 |
Correct |
3 ms |
616 KB |
Output is correct |
10 |
Correct |
3 ms |
680 KB |
Output is correct |
11 |
Correct |
3 ms |
680 KB |
Output is correct |
12 |
Correct |
3 ms |
680 KB |
Output is correct |
13 |
Correct |
2 ms |
680 KB |
Output is correct |
14 |
Correct |
2 ms |
680 KB |
Output is correct |
15 |
Correct |
2 ms |
680 KB |
Output is correct |
16 |
Correct |
4 ms |
680 KB |
Output is correct |
17 |
Correct |
3 ms |
680 KB |
Output is correct |
18 |
Correct |
3 ms |
680 KB |
Output is correct |
19 |
Correct |
3 ms |
680 KB |
Output is correct |
20 |
Correct |
4 ms |
680 KB |
Output is correct |
21 |
Correct |
3 ms |
680 KB |
Output is correct |
22 |
Correct |
3 ms |
680 KB |
Output is correct |
23 |
Correct |
3 ms |
680 KB |
Output is correct |
24 |
Correct |
3 ms |
680 KB |
Output is correct |
25 |
Correct |
3 ms |
680 KB |
Output is correct |
26 |
Correct |
2 ms |
680 KB |
Output is correct |
27 |
Correct |
2 ms |
680 KB |
Output is correct |
28 |
Correct |
3 ms |
680 KB |
Output is correct |
29 |
Correct |
2 ms |
680 KB |
Output is correct |
30 |
Correct |
2 ms |
680 KB |
Output is correct |
31 |
Correct |
3 ms |
680 KB |
Output is correct |
32 |
Correct |
2 ms |
680 KB |
Output is correct |
33 |
Correct |
2 ms |
680 KB |
Output is correct |
34 |
Correct |
3 ms |
680 KB |
Output is correct |
35 |
Correct |
3 ms |
680 KB |
Output is correct |
36 |
Correct |
2 ms |
708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
708 KB |
Output is correct |
2 |
Correct |
2 ms |
708 KB |
Output is correct |
3 |
Correct |
3 ms |
708 KB |
Output is correct |
4 |
Correct |
3 ms |
708 KB |
Output is correct |
5 |
Correct |
3 ms |
708 KB |
Output is correct |
6 |
Correct |
3 ms |
708 KB |
Output is correct |
7 |
Correct |
3 ms |
708 KB |
Output is correct |
8 |
Correct |
2 ms |
708 KB |
Output is correct |
9 |
Correct |
3 ms |
708 KB |
Output is correct |
10 |
Correct |
3 ms |
708 KB |
Output is correct |
11 |
Correct |
3 ms |
708 KB |
Output is correct |
12 |
Correct |
3 ms |
708 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
3 ms |
708 KB |
Output is correct |
15 |
Correct |
3 ms |
708 KB |
Output is correct |
16 |
Correct |
3 ms |
708 KB |
Output is correct |
17 |
Correct |
4 ms |
708 KB |
Output is correct |
18 |
Correct |
3 ms |
708 KB |
Output is correct |
19 |
Correct |
3 ms |
708 KB |
Output is correct |
20 |
Correct |
4 ms |
708 KB |
Output is correct |
21 |
Correct |
3 ms |
708 KB |
Output is correct |
22 |
Correct |
3 ms |
708 KB |
Output is correct |
23 |
Correct |
4 ms |
708 KB |
Output is correct |
24 |
Correct |
2 ms |
748 KB |
Output is correct |
25 |
Correct |
4 ms |
756 KB |
Output is correct |
26 |
Correct |
3 ms |
756 KB |
Output is correct |
27 |
Correct |
2 ms |
756 KB |
Output is correct |
28 |
Correct |
2 ms |
756 KB |
Output is correct |
29 |
Correct |
3 ms |
756 KB |
Output is correct |
30 |
Correct |
2 ms |
756 KB |
Output is correct |
31 |
Correct |
3 ms |
756 KB |
Output is correct |
32 |
Correct |
3 ms |
756 KB |
Output is correct |
33 |
Correct |
3 ms |
756 KB |
Output is correct |
34 |
Correct |
3 ms |
756 KB |
Output is correct |
35 |
Correct |
3 ms |
756 KB |
Output is correct |
36 |
Correct |
3 ms |
756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
756 KB |
Output is correct |
2 |
Correct |
3 ms |
812 KB |
Output is correct |
3 |
Correct |
3 ms |
812 KB |
Output is correct |
4 |
Correct |
2 ms |
812 KB |
Output is correct |
5 |
Correct |
3 ms |
812 KB |
Output is correct |
6 |
Correct |
2 ms |
812 KB |
Output is correct |
7 |
Correct |
3 ms |
812 KB |
Output is correct |
8 |
Correct |
3 ms |
812 KB |
Output is correct |
9 |
Correct |
3 ms |
812 KB |
Output is correct |
10 |
Correct |
2 ms |
812 KB |
Output is correct |
11 |
Correct |
3 ms |
812 KB |
Output is correct |
12 |
Correct |
3 ms |
812 KB |
Output is correct |
13 |
Correct |
3 ms |
812 KB |
Output is correct |
14 |
Correct |
2 ms |
812 KB |
Output is correct |
15 |
Correct |
2 ms |
812 KB |
Output is correct |
16 |
Correct |
5 ms |
812 KB |
Output is correct |
17 |
Correct |
3 ms |
812 KB |
Output is correct |
18 |
Correct |
3 ms |
812 KB |
Output is correct |
19 |
Correct |
4 ms |
812 KB |
Output is correct |
20 |
Correct |
4 ms |
812 KB |
Output is correct |
21 |
Correct |
3 ms |
812 KB |
Output is correct |
22 |
Correct |
2 ms |
812 KB |
Output is correct |
23 |
Correct |
3 ms |
812 KB |
Output is correct |
24 |
Correct |
3 ms |
812 KB |
Output is correct |
25 |
Correct |
3 ms |
812 KB |
Output is correct |
26 |
Correct |
2 ms |
812 KB |
Output is correct |
27 |
Correct |
4 ms |
812 KB |
Output is correct |
28 |
Correct |
3 ms |
812 KB |
Output is correct |
29 |
Correct |
2 ms |
812 KB |
Output is correct |
30 |
Correct |
4 ms |
812 KB |
Output is correct |
31 |
Correct |
3 ms |
812 KB |
Output is correct |
32 |
Correct |
4 ms |
812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
812 KB |
Output is correct |
2 |
Correct |
4 ms |
812 KB |
Output is correct |
3 |
Correct |
3 ms |
812 KB |
Output is correct |
4 |
Correct |
3 ms |
812 KB |
Output is correct |
5 |
Correct |
3 ms |
812 KB |
Output is correct |
6 |
Correct |
2 ms |
812 KB |
Output is correct |
7 |
Correct |
3 ms |
812 KB |
Output is correct |
8 |
Correct |
2 ms |
812 KB |
Output is correct |
9 |
Correct |
2 ms |
812 KB |
Output is correct |
10 |
Correct |
4 ms |
812 KB |
Output is correct |
11 |
Correct |
3 ms |
812 KB |
Output is correct |
12 |
Correct |
3 ms |
812 KB |
Output is correct |
13 |
Correct |
3 ms |
812 KB |
Output is correct |
14 |
Correct |
3 ms |
812 KB |
Output is correct |
15 |
Correct |
3 ms |
812 KB |
Output is correct |
16 |
Correct |
3 ms |
812 KB |
Output is correct |
17 |
Correct |
4 ms |
812 KB |
Output is correct |
18 |
Correct |
2 ms |
812 KB |
Output is correct |
19 |
Correct |
3 ms |
812 KB |
Output is correct |
20 |
Correct |
4 ms |
812 KB |
Output is correct |
21 |
Correct |
3 ms |
812 KB |
Output is correct |
22 |
Correct |
3 ms |
812 KB |
Output is correct |
23 |
Correct |
3 ms |
812 KB |
Output is correct |
24 |
Correct |
3 ms |
812 KB |
Output is correct |
25 |
Correct |
3 ms |
812 KB |
Output is correct |
26 |
Correct |
3 ms |
812 KB |
Output is correct |
27 |
Correct |
2 ms |
812 KB |
Output is correct |
28 |
Correct |
3 ms |
812 KB |
Output is correct |
29 |
Correct |
3 ms |
812 KB |
Output is correct |
30 |
Correct |
3 ms |
812 KB |
Output is correct |
31 |
Correct |
2 ms |
812 KB |
Output is correct |
32 |
Correct |
3 ms |
812 KB |
Output is correct |
33 |
Correct |
2 ms |
812 KB |
Output is correct |
34 |
Correct |
3 ms |
812 KB |
Output is correct |
35 |
Correct |
3 ms |
812 KB |
Output is correct |
36 |
Correct |
4 ms |
812 KB |
Output is correct |
37 |
Correct |
3 ms |
812 KB |
Output is correct |
38 |
Correct |
3 ms |
812 KB |
Output is correct |
39 |
Correct |
3 ms |
812 KB |
Output is correct |
40 |
Correct |
3 ms |
812 KB |
Output is correct |
41 |
Correct |
3 ms |
812 KB |
Output is correct |
42 |
Correct |
3 ms |
812 KB |
Output is correct |
43 |
Correct |
2 ms |
812 KB |
Output is correct |
44 |
Correct |
2 ms |
812 KB |
Output is correct |
45 |
Correct |
3 ms |
812 KB |
Output is correct |
46 |
Correct |
2 ms |
824 KB |
Output is correct |
47 |
Correct |
3 ms |
828 KB |
Output is correct |
48 |
Correct |
3 ms |
832 KB |
Output is correct |
49 |
Correct |
4 ms |
844 KB |
Output is correct |
50 |
Correct |
3 ms |
852 KB |
Output is correct |
51 |
Correct |
4 ms |
864 KB |
Output is correct |
52 |
Correct |
3 ms |
864 KB |
Output is correct |
53 |
Correct |
5 ms |
884 KB |
Output is correct |
54 |
Correct |
4 ms |
888 KB |
Output is correct |
55 |
Correct |
3 ms |
888 KB |
Output is correct |
56 |
Correct |
3 ms |
888 KB |
Output is correct |
57 |
Correct |
2 ms |
888 KB |
Output is correct |
58 |
Correct |
3 ms |
888 KB |
Output is correct |
59 |
Correct |
3 ms |
888 KB |
Output is correct |
60 |
Correct |
3 ms |
888 KB |
Output is correct |
61 |
Incorrect |
3 ms |
888 KB |
Output isn't correct |
62 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
888 KB |
Output is correct |
2 |
Correct |
3 ms |
888 KB |
Output is correct |
3 |
Correct |
3 ms |
888 KB |
Output is correct |
4 |
Correct |
3 ms |
888 KB |
Output is correct |
5 |
Correct |
3 ms |
888 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
3 ms |
888 KB |
Output is correct |
8 |
Correct |
4 ms |
888 KB |
Output is correct |
9 |
Correct |
2 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
888 KB |
Output is correct |
13 |
Correct |
3 ms |
888 KB |
Output is correct |
14 |
Correct |
3 ms |
888 KB |
Output is correct |
15 |
Correct |
2 ms |
888 KB |
Output is correct |
16 |
Correct |
3 ms |
888 KB |
Output is correct |
17 |
Correct |
3 ms |
888 KB |
Output is correct |
18 |
Correct |
4 ms |
888 KB |
Output is correct |
19 |
Correct |
3 ms |
888 KB |
Output is correct |
20 |
Correct |
3 ms |
888 KB |
Output is correct |
21 |
Correct |
3 ms |
888 KB |
Output is correct |
22 |
Correct |
2 ms |
888 KB |
Output is correct |
23 |
Correct |
2 ms |
888 KB |
Output is correct |
24 |
Correct |
3 ms |
888 KB |
Output is correct |
25 |
Correct |
3 ms |
888 KB |
Output is correct |
26 |
Correct |
2 ms |
888 KB |
Output is correct |
27 |
Correct |
4 ms |
888 KB |
Output is correct |
28 |
Correct |
3 ms |
888 KB |
Output is correct |
29 |
Correct |
3 ms |
888 KB |
Output is correct |
30 |
Correct |
2 ms |
888 KB |
Output is correct |
31 |
Correct |
3 ms |
888 KB |
Output is correct |
32 |
Correct |
3 ms |
888 KB |
Output is correct |
33 |
Correct |
3 ms |
888 KB |
Output is correct |
34 |
Correct |
3 ms |
888 KB |
Output is correct |
35 |
Correct |
3 ms |
888 KB |
Output is correct |
36 |
Correct |
3 ms |
888 KB |
Output is correct |
37 |
Correct |
3 ms |
888 KB |
Output is correct |
38 |
Correct |
3 ms |
888 KB |
Output is correct |
39 |
Correct |
4 ms |
888 KB |
Output is correct |
40 |
Correct |
4 ms |
888 KB |
Output is correct |
41 |
Correct |
4 ms |
888 KB |
Output is correct |
42 |
Correct |
3 ms |
888 KB |
Output is correct |
43 |
Correct |
2 ms |
888 KB |
Output is correct |
44 |
Correct |
3 ms |
888 KB |
Output is correct |
45 |
Correct |
4 ms |
888 KB |
Output is correct |
46 |
Correct |
2 ms |
888 KB |
Output is correct |
47 |
Correct |
3 ms |
888 KB |
Output is correct |
48 |
Incorrect |
3 ms |
888 KB |
Output isn't correct |
49 |
Halted |
0 ms |
0 KB |
- |