이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2001;
int dp[N], a[N], n, aa, b, dp1[N][N];
ll mx = 0, p[N];
bool works(int bit){
/*
if(aa == 1){
ll most = mx + (1LL << bit);
for(int i=0; i<=n; i++){
dp[i] = 1e9;
}
dp[0] = 0;
for(int i=1; i <= n; i++){
for(int j = 0; j < i; j++){
ll sum = p[i] - p[j];
if((sum|mx) < most){
dp[i] = min(dp[i], dp[j] + 1);
}
}
}
return dp[n]>b;
}
else{
*/
cerr << "BIT " << bit << "\n";
ll most = mx + (1LL << bit);
for(int i=0; i <= n; i++){
for(int j=0; j <= n; j++){
dp1[i][j] = 0;
}
}
dp1[0][0] = 1;
for(int i=1; i<=n; i++){
for(int j=1; j <= i; j++){
for(int k=0; k < i; k++){
if(dp1[k][j-1] && ((p[i] - p[k])|mx)<most){
dp1[i][j]|=1;
}
}
}
}
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++){
cerr << "(" << i << "," << j << ") " << dp1[i][j] << "\n";
}
}
for(int i = aa; i <= b; i++){
if(dp1[n][i]){
return 0;
}
}
return 1;
//}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> aa >> b;
for(int i = 1; i <= n; i++){
cin >> a[i];
p[i] = p[i-1] + a[i];
}
for(int bit = 40; bit >= 0; bit--){
if(works(bit)){
mx += 1LL << bit;
}
}
cout << mx << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |