Submission #730477

#TimeUsernameProblemLanguageResultExecution timeMemory
730477hoainiemBali Sculptures (APIO15_sculpture)C++14
71 / 100
1091 ms5588 KiB
#include <bits/stdc++.h> #define fi first #define se second #define lc id<<1 #define rc id<<1^1 const long long inf = 1e18; using namespace std; typedef pair<int, int> pii; const long long mx = (1LL << 41) - 1; int n, l, r; long long a[2008], orr[2008][2008]; long long ans = 0; bitset<2008>f[2008]; bool check(long long x){ for (int j = 1; j <= r; j++){ for (int i = j; i <= n; i++){ f[j].reset(i); for (int pos = 1; pos <= i && !f[j].test(i); pos++) if (!(x & orr[pos][i]) && f[j - 1].test(pos - 1)) f[j].set(i); } if (f[j].test(n) && j >= l) return true; } return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> l >> r; f[0].reset(); f[0].set(0); for (int j = 1; j <= r; j++) for (int i = 0; i < j; i++) f[j].reset(0); for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) orr[i][j] = orr[i][j - 1] + a[j]; for (long long i = 1LL << 40; i > 0; i >>= 1) ans += i * check(ans + i); cout << (long long)(mx ^ ans); return 0; }
#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...