Submission #21948

#TimeUsernameProblemLanguageResultExecution timeMemory
21948mohammad_kilaniBali Sculptures (APIO15_sculpture)C++14
0 / 100
0 ms3024 KiB
#include<bits/stdc++.h> using namespace std; const int N = 101; int n , a , b , arr[N]; bool dp[N][N][50]; bool vis[N][N][50]; bool cantake[N][N]; bool solve(int i,int j,int bit){ if(j > b) return 0; if(i == n){ if(j >= a && j <= b) return 1; return 0; } if(vis[i][j][bit]) return dp[i][j][bit]; vis[i][j][bit] = true; long long sum = 0; bool can = false; for(int k=i;k<n;k++){ sum+=(long long)arr[k]; if(((sum >> (long long)bit)&1) == 0 && cantake[k+1][j+1] && solve(k+1,j+1,bit)){ can = true; } } if(can){ sum =0 ; for(int k=i;k<n;k++){ sum+=(long long)arr[k]; if(!(((sum >> bit)&1) == 0 && cantake[k+1][j+1] && solve(k+1,j+1,bit))){ cantake[k+1][j+1] = false; } } } dp[i][j][bit] = can; return dp[i][j][bit]; } int main(){ //freopen("in.txt","r",stdin); memset(dp,-1,sizeof(dp)); memset(cantake,1,sizeof(cantake)); scanf("%d%d%d",&n,&a,&b); for(int i=0;i<n;i++) scanf("%d",&arr[i]); long long ans = 0 ; for(int i=46;i>=0;i--){ if(!solve(0,0,i)){ ans |= ((long long)1 << (long long)i); } } cout << ans << endl; return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:43:29: 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:45:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
                            ^
#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...