Submission #1031346

#TimeUsernameProblemLanguageResultExecution timeMemory
1031346_8_8_Bali Sculptures (APIO15_sculpture)C++17
100 / 100
62 ms608 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e3 + 21, MOD = (int)1e9+7; int n,a,b,x[N],dp[N]; bool pd[105][105]; void solve(){ ll cur = 0,res = 0; pd[0][0] = 1; for(ll c = 41;c >= 0;c--){ for(int i = 1;i <= n;i++){ for(int k = 1;k <= n;k++){ pd[i][k] = 0; } } cur += (1ll << c); for(int i = 1;i <= n;i++){ ll s = 0; for(int j = i;j >= 1;j--){ s += x[j]; if((s & cur) == 0) { for(int f = 1;f <= n;f++){ pd[i][f] |= pd[j - 1][f - 1]; } } } } bool ok = false; for(int j = a;j <= b;j++){ ok |= pd[n][j]; } if(!ok){ res += (1ll << c); cur -= (1ll << c); } } cout << res; } void test() { cin >> n >> a >> b; for(int i = 1;i <= n;i++) { cin >> x[i]; } if(a != 1){ solve(); return; } ll cur = 0,res = 0; for(ll c = 41;c >= 0;c--){ for(int i = 1;i <= n;i++){ dp[i] = 1e9; } cur += (1ll << c); for(int i = 1;i <= n;i++){ ll s = 0; for(int j = i;j >= 1;j--){ s += x[j]; if((s & cur) == 0) { dp[i] = min(dp[i],dp[j - 1] + 1); } } } if(dp[n] > b){ cur -= (1ll << c); res += (1ll << c); } } cout << res; } int main() { ios_base::sync_with_stdio(false);cin.tie(0); int t = 1; // cin >> t; while(t--) { test(); } }
#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...