# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495744 | 2021-12-20T04:08:01 Z | ntabc05101 | Bali Sculptures (APIO15_sculpture) | C++14 | 1 ms | 316 KB |
#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; int y[n + 1]; y[0] = 0; for (int i = 1; i <= n; i++) { cin >> y[i]; y[i] += y[i - 1]; } int 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 = 0; for (int j = a; j <= b; j++) { if (dp[n][j]) { chk = 1; break; } } res |= chk << x; } cout << res << "\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 308 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 316 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |