Submission #527586

# Submission time Handle Problem Language Result Execution time Memory
527586 2022-02-17T17:34:16 Z SlavicG Bali Sculptures (APIO15_sculpture) C++17
37 / 100
49 ms 16072 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

const int N = 2005;
ll p[N];
int sum(int l, int r) {
    return p[r] - (l ? p[l - 1] : 0);
}

//dp[index][OR][number of subarrays] = 1 if possible to obtain such partition

int dp[N][N];
ll excluded;

bool check(ll k, int n, vector<ll>& a, int A, int B) {
    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 = 0;j < i; ++j) {
            ll s = sum(j, i - 1);
            if((s & excluded) || (s & (1LL << k))) continue;
            for(int x = 0;x < n; ++x) {
                dp[i][x + 1] |= dp[j][x];
            }
        }
    }
    for(int j = A; j <= B; ++j) {
        if(dp[n][j]) return true;
    }
    return false;
}

void solve() { 
    ll n, A, B;
    cin >> n >> A >> B;
    vector<ll> a(n);
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        p[i] = (i ? p[i - 1] : 0) + a[i];
    }

    ll ans = 0;
    for(ll pw = 20; pw >= 0; --pw) {
        if(check(pw, n, a, A, B)) {
            excluded += (1LL << pw);
        } else {
            ans += (1LL << pw);
        }
    }
    cout << ans << "\n";
} 
 
int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 41 ms 15948 KB Output is correct
2 Correct 48 ms 16024 KB Output is correct
3 Correct 39 ms 15948 KB Output is correct
4 Correct 40 ms 16028 KB Output is correct
5 Correct 39 ms 16044 KB Output is correct
6 Correct 43 ms 15948 KB Output is correct
7 Correct 39 ms 15948 KB Output is correct
8 Correct 40 ms 16004 KB Output is correct
9 Correct 40 ms 15948 KB Output is correct
10 Correct 40 ms 16032 KB Output is correct
11 Correct 42 ms 15948 KB Output is correct
12 Correct 41 ms 15948 KB Output is correct
13 Correct 40 ms 16024 KB Output is correct
14 Correct 40 ms 15948 KB Output is correct
15 Correct 39 ms 15948 KB Output is correct
16 Correct 43 ms 16028 KB Output is correct
17 Correct 40 ms 15944 KB Output is correct
18 Correct 46 ms 15948 KB Output is correct
19 Correct 47 ms 16044 KB Output is correct
20 Correct 41 ms 15948 KB Output is correct
21 Correct 39 ms 15948 KB Output is correct
22 Correct 40 ms 15948 KB Output is correct
23 Correct 40 ms 15948 KB Output is correct
24 Correct 43 ms 16032 KB Output is correct
25 Correct 44 ms 16036 KB Output is correct
26 Correct 47 ms 16028 KB Output is correct
27 Incorrect 41 ms 15948 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 16028 KB Output is correct
2 Correct 39 ms 16028 KB Output is correct
3 Correct 39 ms 16028 KB Output is correct
4 Correct 40 ms 15948 KB Output is correct
5 Correct 40 ms 15948 KB Output is correct
6 Correct 39 ms 15948 KB Output is correct
7 Correct 41 ms 15948 KB Output is correct
8 Correct 45 ms 15948 KB Output is correct
9 Correct 42 ms 16036 KB Output is correct
10 Correct 39 ms 15948 KB Output is correct
11 Correct 41 ms 15948 KB Output is correct
12 Correct 41 ms 15948 KB Output is correct
13 Correct 38 ms 15948 KB Output is correct
14 Correct 45 ms 16032 KB Output is correct
15 Correct 45 ms 15948 KB Output is correct
16 Correct 42 ms 16028 KB Output is correct
17 Correct 39 ms 16028 KB Output is correct
18 Correct 39 ms 15948 KB Output is correct
19 Correct 39 ms 16028 KB Output is correct
20 Correct 43 ms 15948 KB Output is correct
21 Correct 39 ms 16028 KB Output is correct
22 Correct 41 ms 16032 KB Output is correct
23 Correct 40 ms 15948 KB Output is correct
24 Correct 39 ms 16028 KB Output is correct
25 Correct 39 ms 15932 KB Output is correct
26 Correct 40 ms 16036 KB Output is correct
27 Correct 40 ms 16028 KB Output is correct
28 Correct 38 ms 15948 KB Output is correct
29 Correct 40 ms 15948 KB Output is correct
30 Correct 44 ms 16040 KB Output is correct
31 Correct 49 ms 16032 KB Output is correct
32 Correct 40 ms 16028 KB Output is correct
33 Correct 39 ms 16028 KB Output is correct
34 Correct 39 ms 15948 KB Output is correct
35 Correct 38 ms 15948 KB Output is correct
36 Correct 40 ms 16024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 16028 KB Output is correct
2 Correct 40 ms 15948 KB Output is correct
3 Correct 41 ms 16024 KB Output is correct
4 Correct 41 ms 16032 KB Output is correct
5 Correct 44 ms 16024 KB Output is correct
6 Correct 43 ms 16032 KB Output is correct
7 Correct 49 ms 16028 KB Output is correct
8 Correct 40 ms 16036 KB Output is correct
9 Correct 39 ms 16036 KB Output is correct
10 Correct 43 ms 16072 KB Output is correct
11 Correct 40 ms 16048 KB Output is correct
12 Correct 39 ms 15948 KB Output is correct
13 Correct 39 ms 15948 KB Output is correct
14 Correct 42 ms 15948 KB Output is correct
15 Correct 43 ms 15948 KB Output is correct
16 Correct 42 ms 15948 KB Output is correct
17 Correct 41 ms 15948 KB Output is correct
18 Correct 43 ms 15948 KB Output is correct
19 Correct 40 ms 15948 KB Output is correct
20 Correct 40 ms 15948 KB Output is correct
21 Correct 40 ms 15948 KB Output is correct
22 Correct 45 ms 16028 KB Output is correct
23 Correct 41 ms 16024 KB Output is correct
24 Correct 46 ms 15948 KB Output is correct
25 Correct 41 ms 15948 KB Output is correct
26 Correct 47 ms 15940 KB Output is correct
27 Correct 44 ms 16036 KB Output is correct
28 Correct 48 ms 15948 KB Output is correct
29 Correct 43 ms 15948 KB Output is correct
30 Correct 46 ms 15948 KB Output is correct
31 Correct 43 ms 15948 KB Output is correct
32 Correct 45 ms 15936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 15948 KB Output is correct
2 Correct 41 ms 16068 KB Output is correct
3 Correct 44 ms 16024 KB Output is correct
4 Correct 41 ms 16028 KB Output is correct
5 Correct 44 ms 15948 KB Output is correct
6 Correct 42 ms 15948 KB Output is correct
7 Correct 39 ms 15948 KB Output is correct
8 Correct 41 ms 16024 KB Output is correct
9 Correct 41 ms 15996 KB Output is correct
10 Correct 38 ms 16040 KB Output is correct
11 Correct 41 ms 16028 KB Output is correct
12 Correct 40 ms 16008 KB Output is correct
13 Correct 40 ms 16024 KB Output is correct
14 Correct 39 ms 16024 KB Output is correct
15 Correct 39 ms 15948 KB Output is correct
16 Correct 42 ms 15964 KB Output is correct
17 Correct 39 ms 16032 KB Output is correct
18 Correct 41 ms 15948 KB Output is correct
19 Correct 41 ms 16028 KB Output is correct
20 Correct 40 ms 15948 KB Output is correct
21 Correct 47 ms 16028 KB Output is correct
22 Correct 38 ms 16024 KB Output is correct
23 Correct 38 ms 15948 KB Output is correct
24 Correct 39 ms 15948 KB Output is correct
25 Correct 40 ms 15940 KB Output is correct
26 Correct 39 ms 15948 KB Output is correct
27 Incorrect 41 ms 15948 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 16032 KB Output is correct
2 Correct 39 ms 16028 KB Output is correct
3 Correct 37 ms 15972 KB Output is correct
4 Correct 38 ms 15948 KB Output is correct
5 Correct 38 ms 15948 KB Output is correct
6 Correct 41 ms 16040 KB Output is correct
7 Correct 39 ms 15952 KB Output is correct
8 Correct 41 ms 16024 KB Output is correct
9 Correct 39 ms 15948 KB Output is correct
10 Correct 48 ms 16024 KB Output is correct
11 Correct 39 ms 16024 KB Output is correct
12 Correct 39 ms 15948 KB Output is correct
13 Correct 38 ms 16024 KB Output is correct
14 Incorrect 41 ms 15948 KB Output isn't correct
15 Halted 0 ms 0 KB -