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>
using namespace std;
#define MAXN 2003
typedef long long lld;
int N, A, B;
int X[MAXN], E[MAXN];
bool D[101][101];
lld S[MAXN];
bool w[MAXN][MAXN];
int main()
{
scanf("%d%d%d", &N, &A, &B);
for (int i=1;i<=N;i++) scanf("%d", X+i), S[i] = S[i-1] + X[i];
lld msk = 0;
for (int b=40;b>=0;b--){
msk <<= 1;
for (int i=0;i<N;i++) for (int j=i+1;j<=N;j++){
w[i][j] = (((S[j]-S[i]) >> b) | msk) == msk;
}
if (A == 1){
E[0] = 0;
for (int i=1;i<=N;i++){
E[i] = 2e9;
for (int j=0;j<i;j++) if (w[j][i]){
if (E[j] >= 0) E[i] = min(E[i], E[j]+1);
}
}
if (E[N] > B) msk++;
}else{
D[0][0] = 1;
for (int i=1;i<=B;i++){
for (int j=1;j<=N;j++){
D[i][j] = 0;
for (int k=0;k<j;k++) if (D[i-1][k] && w[k][j])
D[i][j] = 1;
}
}
bool sw = 0;
for (int i=A;i<=B;i++) if (D[i][N]) sw = 1;
if (!sw) msk++;
}
}
printf("%lld\n", msk);
}
# | 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... |