Submission #24675

#TimeUsernameProblemLanguageResultExecution timeMemory
24675chan492811Bali Sculptures (APIO15_sculpture)C++11
100 / 100
176 ms1184 KiB
#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)

sculpture.cpp: In function 'bool make(int)':
sculpture.cpp:14:27: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
                 if((sum[i]-sum[j]|res)==res) table[i]=min(table[i],table[j]+1);
                           ^
sculpture.cpp:23:31: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
                     if((sum[i]-sum[j]|res)==res){
                               ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:39:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&n,&a,&b);
                               ^
sculpture.cpp:41:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&sum[i]); sum[i]+=sum[i-1];
                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...