# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
24675 | chan492811 | Bali Sculptures (APIO15_sculpture) | C++11 | 176 ms | 1184 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
int n,a,b;
ll sum[2010],res;
int table[2010],table2[110][110];
bool make(int flag){
int i,j,k;
if(flag){
for(i=1;i<=n;i++){
for(j=0;j<i;j++){
if((sum[i]-sum[j]|res)==res) table[i]=min(table[i],table[j]+1);
}
}
if(table[n]<=b) return 1; return 0;
}else{
for(k=1;k<=b;k++){
for(i=1;i<=n;i++){
table2[k][i]=0;
for(j=0;j<i;j++){
if((sum[i]-sum[j]|res)==res){
table2[k][i]= max(table2[k][i],table2[k-1][j] ? 1 : 0 );
}
}
}
}
for(i=a;i<=b;i++){
if(table2[i][n]) return 1;
}
return 0;
}
}
int main(){
int j;
ll i;
ll now;
scanf("%d %d %d",&n,&a,&b);
for(i=1;i<=n;i++){
scanf("%lld",&sum[i]); sum[i]+=sum[i-1];
}
res=1ll<<50; res--;
for(i=49;i>=0;i--){
for(j=1;j<2010;j++) table[j]=21e8;
table2[0][0]=1;
now=(1ll<<i);
res-=now;
if(a==1){
if(!make(1)) res+=now;
}else{
if(!make(0)) res+=now;
}
}
printf("%lld",res);
return 0;
}
Compilation message (stderr)
# | 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... |