Submission #102625

# Submission time Handle Problem Language Result Execution time Memory
102625 2019-03-26T09:59:36 Z lyc Bali Sculptures (APIO15_sculpture) C++14
50 / 100
101 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int INF = 1e9;

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, a, b; cin >> n >> a >> b;
    int x[n+1]; ll p[n+1]; p[0] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
        p[i] = p[i-1] + x[i];
    }

    ll ans = 0, mask = 0;
    if (a == 1) {
        for (int k = 41; k >= 0; --k) {
            mask |= (1LL<<k);
            int dp[n+2]; dp[n+1] = 0;
            for (int i = n; i >= 1; --i) {
                dp[i] = INF;
                for (int j = i; j <= n; ++j) {
                    ll sum = p[j] - p[i-1];
                    if ((mask&sum) == 0) dp[i] = min(dp[i], dp[j+1]+1);
                }
            }
            //cout << k << " :: " << ans << " " << dp[1] << endl;
            if (dp[1] > b) ans |= 1LL<<k, mask &= ~(1LL<<k);
            //if (dp[1] > b) cout << "BAD BIT " << k << endl;
        }
    }
    else {
        for (int k = 41; k >= 0; --k) {
            mask |= (1LL<<k);
            bool dp[n+2][b+1]; memset(dp[n+1], 1, sizeof dp[n+1]);
            
            for (int i = n; i >= 1; --i) {
                for (int x = 0; x <= b; ++x) {
                    dp[i][x] = 0;
                    if (x) for (int j = i; j <= n; ++j) {
                        ll sum = p[j] - p[i-1];
                        if ((mask&sum) == 0) dp[i][x] |= dp[j+1][x-1];
                    }
                }
            }

            bool ok = false;
            for (int x = a; x <= b; ++x) if (dp[1][x]) {
                ok = true;
                break;
            }
            //cout << k << " :: " << ans << endl;
            //cout << '\t'; for (int i = a; i <= b; ++i) cout << dp[1][i] << ' '; cout << endl;
            if (!ok) ans |= 1LL<<k, mask &= ~(1LL<<k);
            //if (!ok) cout << "BAD BIT " << k << endl;
        }
    }
    cout << ans << '\n';
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Incorrect 2 ms 256 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Incorrect 2 ms 256 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Incorrect 2 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 356 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 512 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 4 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 4 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 0 ms 256 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 13 ms 384 KB Output is correct
53 Correct 20 ms 392 KB Output is correct
54 Correct 25 ms 384 KB Output is correct
55 Correct 30 ms 400 KB Output is correct
56 Correct 89 ms 384 KB Output is correct
57 Correct 83 ms 428 KB Output is correct
58 Correct 80 ms 428 KB Output is correct
59 Correct 89 ms 444 KB Output is correct
60 Correct 90 ms 440 KB Output is correct
61 Correct 3 ms 356 KB Output is correct
62 Correct 15 ms 428 KB Output is correct
63 Correct 27 ms 412 KB Output is correct
64 Correct 34 ms 400 KB Output is correct
65 Correct 46 ms 432 KB Output is correct
66 Correct 70 ms 424 KB Output is correct
67 Correct 101 ms 440 KB Output is correct
68 Correct 89 ms 424 KB Output is correct
69 Correct 90 ms 428 KB Output is correct