Submission #925490

# Submission time Handle Problem Language Result Execution time Memory
925490 2024-02-11T19:39:02 Z VMaksimoski008 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int32_t main() {
    int n, a, b;
    cin >> n >> a >> b;

    vector<ll> pref(n+1);    
    for(int i=1; i<=n; i++) cin >> pref[i], pref[i] += pref[i-1];

    auto query = [&](int l, int r) { return pref[r] - pref[l-1]; };

    // if(a == 1) {
    //     ll mask = 0;

    //     for(int bit=51; bit>=0; bit--) {
    //         ll mask2 = mask | (1ll << bit);
    //         vector<int> dp(n+1, 1e9);
    //         dp[0] = 0;

    //         for(int i=1; i<=n; i++) {
    //             for(int j=i; j>=1; j--) {
    //                 if(query(j, i) & mask2) continue;
    //                 dp[i] = min(dp[i], dp[j-1] + 1);
    //             }
    //         }
            
    //         if(dp[n] <= b) mask |= (1ll << bit);
    //     }

    //     mask ^= ((1ll << 52) - 1);
    //     cout << mask << '\n';
    //     return 0;
    // }

    ll mask = 0, dp[n+1][n+1];
	for(int bit=51; bit>=0; bit--) {
        ll mask2 = mask | (1ll << bit);
        for(int i=0; i<=n; i++)
            for(int j=0; j<=n; j++) dp[i][j] = 0;
        dp[0][0] = 1;

        for(int i=1; i<=n; i++) {
            for(int j=1; j<=n; j++) {
                for(int k=1; k<=i; k++) {
                    if(query(k, j) & mask2) continue;
                    dp[i][j] |= dp[k-1][j-1];
                }
            }
        }

        for(int j=a; j<=b; j++) {
            if(dp[n][j]) {
                mask |= (1ll << bit);
                break;
            }
        }
	}

	mask ^= ((1ll << 52) - 1);
	cout << mask << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -