#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,inf);
dp.assign(n+1,_);
rep(i,0,n) dp[i][0] = 0;
dp[0][0] = 1;
rep(i,0,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 |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
360 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
3 ms |
524 KB |
Output is correct |
6 |
Correct |
3 ms |
564 KB |
Output is correct |
7 |
Correct |
3 ms |
648 KB |
Output is correct |
8 |
Correct |
3 ms |
648 KB |
Output is correct |
9 |
Correct |
2 ms |
648 KB |
Output is correct |
10 |
Correct |
3 ms |
648 KB |
Output is correct |
11 |
Correct |
4 ms |
648 KB |
Output is correct |
12 |
Correct |
3 ms |
648 KB |
Output is correct |
13 |
Correct |
3 ms |
668 KB |
Output is correct |
14 |
Runtime error |
4 ms |
800 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
844 KB |
Output is correct |
2 |
Correct |
2 ms |
844 KB |
Output is correct |
3 |
Correct |
3 ms |
844 KB |
Output is correct |
4 |
Correct |
3 ms |
844 KB |
Output is correct |
5 |
Correct |
3 ms |
844 KB |
Output is correct |
6 |
Correct |
3 ms |
844 KB |
Output is correct |
7 |
Correct |
3 ms |
844 KB |
Output is correct |
8 |
Correct |
3 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
4 ms |
872 KB |
Output is correct |
11 |
Correct |
2 ms |
872 KB |
Output is correct |
12 |
Correct |
3 ms |
872 KB |
Output is correct |
13 |
Correct |
3 ms |
872 KB |
Output is correct |
14 |
Runtime error |
3 ms |
920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
920 KB |
Output is correct |
2 |
Correct |
2 ms |
972 KB |
Output is correct |
3 |
Correct |
3 ms |
972 KB |
Output is correct |
4 |
Correct |
3 ms |
972 KB |
Output is correct |
5 |
Correct |
2 ms |
972 KB |
Output is correct |
6 |
Correct |
2 ms |
972 KB |
Output is correct |
7 |
Correct |
3 ms |
972 KB |
Output is correct |
8 |
Correct |
3 ms |
984 KB |
Output is correct |
9 |
Correct |
3 ms |
984 KB |
Output is correct |
10 |
Correct |
3 ms |
984 KB |
Output is correct |
11 |
Correct |
2 ms |
996 KB |
Output is correct |
12 |
Correct |
3 ms |
996 KB |
Output is correct |
13 |
Correct |
3 ms |
996 KB |
Output is correct |
14 |
Correct |
4 ms |
996 KB |
Output is correct |
15 |
Correct |
3 ms |
996 KB |
Output is correct |
16 |
Correct |
3 ms |
996 KB |
Output is correct |
17 |
Correct |
2 ms |
996 KB |
Output is correct |
18 |
Correct |
3 ms |
996 KB |
Output is correct |
19 |
Correct |
4 ms |
996 KB |
Output is correct |
20 |
Correct |
2 ms |
996 KB |
Output is correct |
21 |
Correct |
3 ms |
996 KB |
Output is correct |
22 |
Correct |
3 ms |
996 KB |
Output is correct |
23 |
Correct |
3 ms |
996 KB |
Output is correct |
24 |
Correct |
3 ms |
996 KB |
Output is correct |
25 |
Correct |
3 ms |
996 KB |
Output is correct |
26 |
Correct |
3 ms |
996 KB |
Output is correct |
27 |
Correct |
3 ms |
1056 KB |
Output is correct |
28 |
Correct |
4 ms |
1056 KB |
Output is correct |
29 |
Correct |
4 ms |
1056 KB |
Output is correct |
30 |
Correct |
3 ms |
1056 KB |
Output is correct |
31 |
Correct |
3 ms |
1056 KB |
Output is correct |
32 |
Correct |
4 ms |
1056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1056 KB |
Output is correct |
2 |
Correct |
3 ms |
1056 KB |
Output is correct |
3 |
Correct |
3 ms |
1056 KB |
Output is correct |
4 |
Correct |
4 ms |
1056 KB |
Output is correct |
5 |
Correct |
3 ms |
1056 KB |
Output is correct |
6 |
Correct |
3 ms |
1056 KB |
Output is correct |
7 |
Correct |
3 ms |
1056 KB |
Output is correct |
8 |
Correct |
3 ms |
1056 KB |
Output is correct |
9 |
Correct |
3 ms |
1056 KB |
Output is correct |
10 |
Correct |
3 ms |
1132 KB |
Output is correct |
11 |
Correct |
3 ms |
1132 KB |
Output is correct |
12 |
Correct |
3 ms |
1132 KB |
Output is correct |
13 |
Correct |
3 ms |
1132 KB |
Output is correct |
14 |
Runtime error |
3 ms |
1168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1168 KB |
Output is correct |
2 |
Correct |
3 ms |
1168 KB |
Output is correct |
3 |
Correct |
3 ms |
1168 KB |
Output is correct |
4 |
Correct |
3 ms |
1168 KB |
Output is correct |
5 |
Correct |
3 ms |
1168 KB |
Output is correct |
6 |
Correct |
4 ms |
1168 KB |
Output is correct |
7 |
Correct |
2 ms |
1236 KB |
Output is correct |
8 |
Correct |
2 ms |
1236 KB |
Output is correct |
9 |
Correct |
4 ms |
1236 KB |
Output is correct |
10 |
Correct |
4 ms |
1236 KB |
Output is correct |
11 |
Correct |
3 ms |
1236 KB |
Output is correct |
12 |
Correct |
3 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
14 |
Correct |
2 ms |
1236 KB |
Output is correct |
15 |
Correct |
2 ms |
1236 KB |
Output is correct |
16 |
Correct |
2 ms |
1260 KB |
Output is correct |
17 |
Correct |
3 ms |
1260 KB |
Output is correct |
18 |
Correct |
3 ms |
1260 KB |
Output is correct |
19 |
Correct |
3 ms |
1260 KB |
Output is correct |
20 |
Correct |
3 ms |
1260 KB |
Output is correct |
21 |
Correct |
3 ms |
1260 KB |
Output is correct |
22 |
Correct |
3 ms |
1260 KB |
Output is correct |
23 |
Correct |
3 ms |
1260 KB |
Output is correct |
24 |
Correct |
3 ms |
1260 KB |
Output is correct |
25 |
Correct |
3 ms |
1260 KB |
Output is correct |
26 |
Correct |
3 ms |
1260 KB |
Output is correct |
27 |
Correct |
3 ms |
1260 KB |
Output is correct |
28 |
Correct |
4 ms |
1260 KB |
Output is correct |
29 |
Correct |
3 ms |
1260 KB |
Output is correct |
30 |
Correct |
4 ms |
1260 KB |
Output is correct |
31 |
Correct |
3 ms |
1260 KB |
Output is correct |
32 |
Correct |
3 ms |
1324 KB |
Output is correct |
33 |
Correct |
3 ms |
1324 KB |
Output is correct |
34 |
Correct |
3 ms |
1324 KB |
Output is correct |
35 |
Correct |
3 ms |
1324 KB |
Output is correct |
36 |
Correct |
4 ms |
1324 KB |
Output is correct |
37 |
Correct |
3 ms |
1324 KB |
Output is correct |
38 |
Correct |
4 ms |
1324 KB |
Output is correct |
39 |
Correct |
4 ms |
1324 KB |
Output is correct |
40 |
Correct |
3 ms |
1324 KB |
Output is correct |
41 |
Correct |
4 ms |
1324 KB |
Output is correct |
42 |
Correct |
4 ms |
1376 KB |
Output is correct |
43 |
Correct |
2 ms |
1376 KB |
Output is correct |
44 |
Correct |
3 ms |
1376 KB |
Output is correct |
45 |
Correct |
3 ms |
1376 KB |
Output is correct |
46 |
Correct |
4 ms |
1376 KB |
Output is correct |
47 |
Correct |
3 ms |
1376 KB |
Output is correct |
48 |
Incorrect |
3 ms |
1376 KB |
Output isn't correct |
49 |
Halted |
0 ms |
0 KB |
- |