이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bitset>
using namespace std;
using ll = long long;
const int MAXN = 2077;
ll a[MAXN];
ll minsg_[MAXN];
ll* minsg = minsg_ + 1;
bitset<MAXN> possg_[MAXN];
bitset<MAXN>* possg = possg_ + 1;
signed main() {
int n, A, B;
cin >> n >> A >> B;
for (int i = 0; i < n; ++i)
cin >> a[i];
ll ans = 0;
for (ll bt = 61; bt >= 0; --bt) {
for (int i = 0; i < n; ++i) {
if (A == 1)
minsg[i] = MAXN;
else
possg[i] = 0;
}
possg[-1][0] = 1;
for (int i = 0; i < n; ++i) {
ll sm = 0;
for (int j = i; j >= 0; --j) {
sm += a[j];
if ((sm - (sm & ans)) < (1ll << bt)) {
if (A == 1) {
minsg[i] = min(minsg[i], minsg[j - 1] + 1);
} else {
possg[i] |= possg[j - 1] << 1;
}
}
}
}
if (A == 1) {
if (minsg[n - 1] > B) {
ans |= (1ll << bt);
}
} else {
bool isok = false;
for (int t = A; t <= B && !isok; ++t) {
if (possg[n - 1][t])
isok = true;
}
if (!isok) {
ans |= (1ll << bt);
}
}
}
cout << ans << endl;
}
# | 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... |