Submission #40905

#TimeUsernameProblemLanguageResultExecution timeMemory
40905IvanCBali Sculptures (APIO15_sculpture)C++14
25 / 100
1068 ms14840 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 102; unordered_set<ll> dp[MAXN][MAXN]; int N,A,B; ll soma[MAXN],best; ll calc(int a,int b){return soma[b] - soma[a-1];} void solve(int pos,int resta,ll curOr){ if(resta < 0) return; if(dp[pos][resta].count(curOr)) return; for(ll i = 0;(1LL <<i)<=curOr;i++){ if(curOr & (1LL << i)){ if(dp[pos][resta].count(curOr ^ (1LL << i))) return; } } dp[pos][resta].insert(curOr); if(pos == N + 1){ if(resta != 0) return; best = min(best,curOr); return; } if(resta == 0) return; for(int quebra = pos;quebra<=N;quebra++){ solve(quebra+1,resta - 1,curOr | calc(pos,quebra)); } } int main(){ scanf("%d %d %d",&N,&A,&B); for(int i = 1;i<=N;i++){ scanf("%lld",&soma[i]); soma[i] += soma[i-1]; } best = (ll)1e18; for(int i = A;i<=B;i++) solve(1,i,0); printf("%lld\n",best); return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:29:28: 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:31:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&soma[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...