#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 998244353LL;
template <typename T>
bool chmin(T& a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
};
template <typename T>
bool chmax(T& a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
for(int i = 0; i < v.size(); i++) {
os << v[i] << (i + 1 == v.size() ? "\n" : " ");
}
return os;
}
template <typename T>
vector<T> make_v(size_t a) {
return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
for(auto& e : t) {
fill_v(e, v);
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, a, b;
cin >> n >> a >> b;
if(a > 1) {
return 0;
}
vector<ll> x(n + 10), sum(n + 10);
for(int i = 1; i <= n; i++) {
cin >> x[i];
sum[i] = sum[i - 1] + x[i];
}
ll s = 0;
for(ll k = 60; k >= 0; k--) {
auto dp = make_v<int>(n + 10, n + 10);
fill_v(dp, INF);
dp[0][0] = 0;
for(int i = 1; i <= n; i++) {
for(int j = 0; j < i; j++) {
dp[i][j] = dp[i - 1][j];
if(((sum[i] - sum[j]) ^ s) < (1LL << k)) {
chmin(dp[i][i], dp[i][j] + 1);
}
}
}
if(dp[n][n] > b) {
s += (1LL << k);
}
}
cout << s << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |