# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25047 | kajebiii | Bali Sculptures (APIO15_sculpture) | C++14 | 119 ms | 6340 KiB |
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 REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
const int MAX_N = 2e3 + 100, LOG_NR = 43;
int N, A, B, Nr[MAX_N];
bool Dy4[MAX_N][MAX_N]; int Dy5[MAX_N];
int main() {
cin >> N >> A >> B;
for(int i=1; i<=N; i++) scanf("%d", &Nr[i]);
ll memo = 0, ans = 0;
for(int s=LOG_NR-1; s>=0; s--) {
ll nowS = 1ll << s;
if(N <= 100 && A != 1) {
for(int i=0; i<=N; i++) for(int j=0; j<=N; j++) Dy4[i][j] = false;
Dy4[0][0] = true;
for(int i=1; i<=N; i++) {
ll now = 0;
for(int j=i; j>=1; j--) {
now += Nr[j];
if(now & memo) continue;
if( (now & nowS) == 0)
for(int k=0; k<=min(B, j-1); k++)
if(Dy4[k][j-1])
Dy4[k+1][i] = true;
}
}
bool isZero = false;
for(int k=A; k<=B; k++)
if(Dy4[k][N]) {
memo += nowS;
isZero = true;
break;
}
if(!isZero) ans += nowS;
} else {
for(int i=0; i<=N; i++) Dy5[i] = INF;
Dy5[0] = 0;
for(int i=1; i<=N; i++) {
ll now = 0;
for(int j=i; j>=1; j--) {
now += Nr[j];
if(now & memo) continue;
if((now & nowS) == 0)
Dy5[i] = min(Dy5[i], Dy5[j-1] + 1);
}
}
bool isZero = false;
if(Dy5[N] <= B) {
memo += nowS;
isZero = true;
}
if(!isZero) ans += nowS;
}
}
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | 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... |