# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495912 | ntabc05101 | Bali Sculptures (APIO15_sculpture) | C++14 | 1 ms | 204 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 taskname ""
const int lgN = 40;
int main() {
if (fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
else {
if (fopen(taskname".in", "r")) {
freopen(taskname".in", "r", stdin);
freopen(taskname".out", "w", stdout);
}
}
cin.tie(0)->sync_with_stdio(0);
int n, a, b; cin >> n >> a >> b;
long long y[n + 1];
y[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> y[i]; y[i] += y[i - 1];
}
long long res = 0;
if (a == 1) {
pair<bool, int> dp[n + 1];
for (int x = lgN - 1; ~x; x--) {
dp[0] = {1, 0};
for (int i = 1; i <= n; i++) {
dp[i] = {0, 0};
for (int j = i - 1; ~j; j--) {
if (!(((y[i] - y[j]) ^ res) >> x)) {
dp[i] = max(dp[i], dp[j]);
}
}
dp[i].second--;
}
if (!dp[n].first || -dp[n].second > b) {
res |= 1 << x;
}
}
cout << res << "\n";
}
else {
bool dp[n + 1][n + 1];
for (int x = lgN - 1; ~x; x--) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 1; i <= n; i++) {
for (int k = i - 1; ~k; k--) {
if (!(((y[i] - y[k]) ^ res) >> x)) {
for (int j = 1; j <= i; j++) {
dp[i][j] |= dp[k][j - 1];
}
}
}
}
int chk = 1;
for (int j = a; j <= b; j++) {
if (dp[n][j]) {
chk = 0; break;
}
}
res |= chk << x;
}
cout << res << "\n";
}
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... |