| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 846303 | vjudge1 | Bali Sculptures (APIO15_sculpture) | C++17 | 1 ms | 600 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;
using ll = long long;
const int N1 = 1e2+5;
const int N2 = 2e3+5;
int n, p, q, a[N1], dp2[N2];
ll res = (1ll << 41)-1;
bool dp1[N1][N1];
void sub1() {
for(int i = 40; i >= 0; --i) {
res ^= (1ll << i);
memset(dp1, 0, sizeof(dp1));
dp1[0][0] = 1;
for(int j = 1; j <= n; ++j) {
for(int g = 1; g <= min(j, q); ++g) {
for(int k = 0; k < j; ++k) {
if(((a[j] - a[k]) & res) == (a[j] - a[k])) {
dp1[j][g] |= dp1[k][g-1];
}
}
}
}
bool ok = 0;
for(int j = p; j <= q; ++j) {
ok |= dp1[n][j];
}
if(!ok) res ^= (1ll << i);
}
cout << res;
}
void sub2() {
for(int i = 40; i >= 0; --i) {
res ^= (1ll << i);
memset(dp2, 0x3f, sizeof(dp2));
dp2[0] = 0;
for(int j = 1; j <= n; ++j) {
for(int k = 0; k < j; ++k) {
if(((a[j]-a[k]) & res) == (a[j]-a[k])) {
dp2[j] = min(dp2[j], dp2[k]+1);
}
}
}
if(dp2[n] > q) res ^= (1ll << i);
}
cout << res;
}
signed main() {
if(fopen("test.inp", "r")) {
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> p >> q;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
a[i] += a[i-1];
}
if(p == 1) sub2();
else sub1();
}
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... | ||||
