# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167018 | Hideo | Beautiful row (IZhO12_beauty) | C++14 | 0 ms | 0 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.
// Need to git gud and reach 1900+
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define prev prev123
#define next next123
#define pow pow123
#define left left123
#define right right123
const int N = 2007;
const int INF = 1e9 + 7;
ll a[N];
int n, x, y;
main(){ // If you don't know what to do, check the text box at the bottom
cin >> n >> x >> y;
for (int i = 1; i <= n; i++)
scanf("%lld", &a[i]);
if (x == 1){
int dp[N];
dp[0] = 0;
for (ll j = 45; j >= 0; j--){
ll submask = (mask | (1LL << j)), s = 0;
for (int i = 1; i <= n; i++){
s = 0; dp[i] = INF;
for (int l = i; l >= 1; l--){
s += a[l];
if (!(s & submask))
dp[i] = min(dp[l - 1] + 1, dp[i]);
}
}
if (dp[i] < )
}
}
else {
bool dp[107][107];
memset(dp, false, sizeof(dp));
dp[0][0] = true;
ll mask = 0;
for (ll j = 45; j >= 0; j--){
ll submask = (mask | (1LL << j)), s = 0;
for (int i = 1; i <= n; i++){
dp[i][0] = false;
for (int g = 1; g <= min(i, y); g++){
dp[i][g] = false;
s = 0;
for (int l = i; l >= g; l--){
s += a[l];
if (s & submask)
continue;
dp[i][g] |= dp[l - 1][g - 1];
}
}
}
bool b = false;
for (int i = x; i <= y; i++){
if (dp[n][i]){
b = true;
break;
}
}
if (b)
mask = submask;
}
printf("%lld", (mask ^ ((1LL << 46) - 1)));
}
}
/*
Totally not inspired by BenQ's template
Things you should do:
1. Look for stupid typos in code e.g 1 instead of -1 etc
2. Check if there is no infinite loops
3. "Measure twice, cut once"
4. Stay focused
6 1 3
8 1 2 1 5 4
*/