Submission #21956

#TimeUsernameProblemLanguageResultExecution timeMemory
21956mohammad_kilaniBali Sculptures (APIO15_sculpture)C++14
0 / 100
0 ms3236 KiB
#include<bits/stdc++.h> using namespace std; const int N = 111; int n , a , b , arr[N]; bool dp[N][N][50]; bool vis[N][N][50]; bool cantake[N][N]; void printbinary(long long num){ for(int i=32;i>=0;i--){ cout << ((num>>i)&1); } cout << endl; } bool solve(int i,int j,int bit){ if(!cantake[i][j]) return false; if(j > b) return false; if(i == n){ if(j >= a) return true; return false; } if(vis[i][j][bit] == true) return dp[i][j][bit]; vis[i][j][bit] = true; long long sum = 0 ; bool can = false; vector<int> v; for(int k = i;k<n;k++){ sum += (long long)arr[k]; long long num = (sum >> (long long)bit); if((num&1) == 1){ v.push_back(k+1); continue; } if(solve(k+1,j+1,bit) == true) can = true; else v.push_back(k+1); } if(can){ for(int k=0;k<(int)v.size();k++){ cantake[v[k]][j+1] = false; } } return dp[i][j][bit] = can; } 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:57: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:59: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...