# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334559 | 2020-12-09T12:01:27 Z | neihcr7j | Bali Sculptures (APIO15_sculpture) | C++14 | 1 ms | 384 KB |
#include<bits/stdc++.h> #define submask(i, j) ((i ^ j) == (i - j)) #define maxn 100005 using namespace std; typedef long long ll; int n, A, B; ll f[maxn]; bool check(ll mask, int index) { if (A == 1) { vector < int > d(n + 1, B + 1); d[0] = 0; for (int i = 1; i <= n; ++i) for (int j = 0; j < i; ++j) if (submask((f[i] - f[j]) >> index, mask >> index)) d[i] = min(d[i], d[j] + 1); return d[n] <= B; } 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 j = 0; j < i; ++j) if (submask(((f[i] - f[j]) >> index), (mask >> index))) for (int k = 1; k <= n; ++k) d[i][k] |= d[j][k - 1]; for (int i = A; i <= B; ++i) if (d[n][i]) return 1; return 0; } } int main() { #define TASK "ABC" if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> A >> B; for (int i = 1; i <= n; ++i) { cin >> f[i]; f[i] += f[i - 1]; } ll ans = 0; for (int i = 50; i >= 0; --i) if (!check(ans, i)) ans += (1ll << i); cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |