This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2005 + 5, inf = 4000;
int t, a[maxn], dp[maxn], f[105][105];
main(){
int n, A, B;
cin >> n >> A >> B;
for(int i = 1; i <= n; i++) {
cin >> a[i];
a[i] += a[i - 1];
}
if(A == 1) {
int cur = 0, X = 0;
for(int i = 40; i >= 0; i--) {
X += 1ll << i;
for(int r = 1; r <= n; r++) {
dp[r] = inf;
for(int l = 1; l <= r; l++) {
int sum = (a[r] - a[l - 1]) & X;
if(!((sum ^ cur) & sum)) {
dp[r] = min(dp[l - 1] + 1, dp[r]);
}
}
}
if(dp[n] > B) {
cur += 1ll << i;
}
}
cout << cur;
return 0;
}
int cur = 0, X = 0;
for(int i = 40; i >= 0; i--) {
X += 1ll << i;
for(int r = 1; r <= n; r++) {
f[0][0] = 1;
for(int c = 0; c <= r; c++) f[r][c] = 0;
for(int l = 1; l <= r; l++) {
int sum = (a[r] - a[l - 1]) & X;
if(!((sum ^ cur) & sum)) {
for(int c = 1; c <= r; c++)
f[r][c] |= f[l - 1][c - 1];
}
}
}
int F = 0;
for(int c = A; c <= B; c++) F |= f[n][c];
if(!F) {
cur += 1ll << i;
}
}
cout << cur;
}
Compilation message (stderr)
sculpture.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |