Submission #396659

#TimeUsernameProblemLanguageResultExecution timeMemory
396659leinad2Bali Sculptures (APIO15_sculpture)C++17
71 / 100
39 ms348 KiB
#include<bits/stdc++.h> using namespace std; long long A[110], ans, chk; int n, i, j, k, l, a, b, dp[110][110], dp2[2010]; main() { for(scanf("%d %d %d", &n, &a, &b);i++<n;)scanf("%lld", &A[i]),A[i]+=A[i-1]; if(a!=1) { for(k=39;k>=0;k--) { for(i=0;i++<n;)for(j=0;j++<n;)dp[i][j]=0;dp[0][0]=1; chk+=(1LL<<k); for(i=0;i++<n;)for(j=0;j++<n;)for(l=0;l<i;l++) { if((chk&(A[i]-A[l]))==0&&dp[l][j-1]) { dp[i][j]=1; break; } } bool flag=false; for(i=a;i<=b;i++)if(dp[n][i])flag=true; if(!flag)chk-=(1LL<<k),ans+=(1LL<<k); } } else { for(k=39;k>=0;k--) { for(i=0;i++<n;)dp2[i]=1e9;chk+=(1LL<<k); for(i=0;i++<n;) { for(j=0;j<i;j++) { if((chk&(A[i]-A[j]))==0)dp2[i]=min(dp2[i], dp2[j]+1); } } if(dp2[n]>b)chk-=(1LL<<k),ans+=(1LL<<k); } } cout<<ans; }

Compilation message (stderr)

sculpture.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      |      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:12:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   12 |             for(i=0;i++<n;)for(j=0;j++<n;)dp[i][j]=0;dp[0][0]=1;
      |             ^~~
sculpture.cpp:12:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   12 |             for(i=0;i++<n;)for(j=0;j++<n;)dp[i][j]=0;dp[0][0]=1;
      |                                                      ^~
sculpture.cpp:31:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   31 |             for(i=0;i++<n;)dp2[i]=1e9;chk+=(1LL<<k);
      |             ^~~
sculpture.cpp:31:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   31 |             for(i=0;i++<n;)dp2[i]=1e9;chk+=(1LL<<k);
      |                                       ^~~
sculpture.cpp:7:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     for(scanf("%d %d %d", &n, &a, &b);i++<n;)scanf("%lld", &A[i]),A[i]+=A[i-1];
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:7:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     for(scanf("%d %d %d", &n, &a, &b);i++<n;)scanf("%lld", &A[i]),A[i]+=A[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...