Submission #922827

# Submission time Handle Problem Language Result Execution time Memory
922827 2024-02-06T07:26:37 Z vjudge1 Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 600 KB
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;

template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */

const int N = 2e3 + 7;

int n, a[N], A, B;

ll pre[N];

ll getSum(int i, int j) {
    return pre[j] - pre[i - 1];
}

namespace sub1 {
    const int N = 107;
    const int M = 45;
    bool f[N][N];
    ll solve(int m) {
        ll res = 0;
        FORD(x, 3, 0) {
            FOR(i, 0, n)
                FOR(j, 0, m + 1) f[i][j] = false;
            f[0][0] = true;
            REP(i, 0, n)
                FOR(j, 0, m)
                    if (f[i][j]) {
                        FOR(k, i + 1, n) {
                            ll sum = getSum(i + 1, k);
                            if ((sum & res) == res && (sum & MASK(x)) == 0 && (sum <= res + MASK(x) - 1)) {
                                f[k][j + 1] = true;
                            }
                        }
                    }
            if (f[n][m]) continue;
            res^=MASK(x);
        }
        return res;
    }
    void Process() {
        ll res = 1e18;
        FOR(x, A, B) minimize(res, solve(x));
        cout<<res;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>A>>B;
    FOR(i, 1, n) {
        cin>>a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    if (n <= 100) {
        sub1::Process();
        return 0;
    }
    return 0;

}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -