# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
243374 | 2020-07-01T01:14:09 Z | neihcr7j | Bali Sculptures (APIO15_sculpture) | C++14 | 5 ms | 384 KB |
#include<bits/stdc++.h> #define maxn 2005 #define submask(mask1, mask2) ((mask1 ^ mask2) == mask1 - mask2) using namespace std; typedef long long ll; int n; int l, r; int a[maxn]; bool check(int ret, int is) { if (l == 1) { vector < int > d(n + 1, 0); for (int i = 1; i <= n; ++i) { d[i] = r + 1; for (int j = i - 1; j >= 0; --j) if (submask(ret >> is, (a[i] - a[j]) >> is)) d[i] = min(d[i], d[j] + 1); } return d[n] <= r; } else { vector < vector < int > > d(n + 1, vector < int >(n + 1, 0)); d[0][0] = 1; for (int i = 1; i <= n; ++i) for (int k = 1; k <= r && k <= i; ++k) for (int j = i - 1; j >= 0 && !d[i][k]; --j) if (submask(ret >> is, (a[i] - a[j]) >> is)) d[i][k] |= d[j][k - 1]; for (int k = l; k <= r; ++k) if (d[n][k]) return 1; return 0; } } int main(){ #define TASK "ABC" // freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); ios_base::sync_with_stdio(0); cin >> n; cin >> l >> r; for (int i = 1; i <= n; ++i) { cin >> a[i]; a[i] += a[i - 1]; } int ret = 0; for (int i = 30; i >= 0; --i) if (!check(ret, i)) ret += (1 << i); cout << ret; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 5 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 4 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Incorrect | 4 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 5 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Incorrect | 4 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |