Submission #406819

# Submission time Handle Problem Language Result Execution time Memory
406819 2021-05-18T05:38:48 Z 2qbingxuan Bali Sculptures (APIO15_sculpture) C++14
0 / 100
12 ms 2892 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#ifdef local
#define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define pary(a...) danb(#a, a)
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
    int cnt = sizeof...(T);
    ((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n")));
}
template <typename T> void danb(const char *s, T L, T R) {
    std::cerr << "\033[1;32m[ " << s << " ] = [ ";
    for (int f = 0; L != R; ++L)
        std::cerr << (f++ ? ", " : "") << *L;
    std::cerr << " ]\033[0m\n";
}
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#define pary(...) ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define pb emplace_back

using namespace std;
using ll = int_fast64_t;
const int inf = 1e9;
const int mod = 1000000007;
const int maxn = 2025;
const int maxc = (1 << 18);

ll pre[maxn], a[maxn];
int n, A, B;
/*
bool dp[maxn];
bool ok(ll mask) {
    dp[0] = true;
    for (int i = 1; i <= n; i++) {
        dp[i] = false;
        for (int j = 0; j < i; j++) if (A <= i-j && i-j <= B && !(mask & (pre[i] - pre[j]))) dp[i] |= dp[j];
    }
    return dp[n];
}
*/
bool dp[maxn][maxc];
bool ok(ll x) { return 0; }
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> A >> B;

    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) pre[i+1] = pre[i] + a[i];

    dp[0][0] = true;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++) if (A <= i-j && i-j <= B) {
            int s = pre[i] - pre[j];
            for (int r = 0; r < maxc; r++) dp[i][r | s] |= dp[j][r];
        }
    }
    for (int r = 0; r < maxc; r++) if (dp[n][r]) return cout << r << '\n', 0;
    return 0;

    assert(ok(0));
    ll ans = 0, U = (1LL << 51) - 1;
    for (ll s = 1LL << 50; s; s >>= 1) if (ok(ans + s)) ans += s;
    cout << (U ^ ans) << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1868 KB Output is correct
2 Correct 12 ms 2316 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 5 ms 1612 KB Output is correct
5 Incorrect 6 ms 2892 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 10 ms 2380 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 5 ms 1612 KB Output is correct
5 Incorrect 6 ms 2892 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 10 ms 2380 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 6 ms 1612 KB Output is correct
5 Incorrect 7 ms 2764 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1864 KB Output is correct
2 Correct 10 ms 2380 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 6 ms 1484 KB Output is correct
5 Incorrect 6 ms 2764 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1868 KB Output is correct
2 Correct 10 ms 2368 KB Output is correct
3 Correct 1 ms 472 KB Output is correct
4 Correct 6 ms 1484 KB Output is correct
5 Incorrect 6 ms 2892 KB Output isn't correct
6 Halted 0 ms 0 KB -