Submission #15871

#TimeUsernameProblemLanguageResultExecution timeMemory
15871myungwooBali Sculptures (APIO15_sculpture)C++14
100 / 100
290 ms5680 KiB
#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 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...