Submission #106924

# Submission time Handle Problem Language Result Execution time Memory
106924 2019-04-21T05:43:44 Z TAISA_ Bali Sculptures (APIO15_sculpture) C++14
100 / 100
838 ms 16660 KB
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 998244353LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n + 10), sum(n + 10);
    for(int i = 1; i <= n; i++) {
        cin >> x[i];
        sum[i] = sum[i - 1] + x[i];
    }
    ll s = 0;
    for(ll k = 41; k >= 0; k--) {
        if(a == 1) {
            auto dp = make_v<int>(n + 10, n + 10);
            fill_v(dp, INF);
            dp[0][0] = 0;
            for(int i = 1; i <= n; i++) {
                for(int j = 0; j < i; j++) {
                    dp[i][j] = dp[i - 1][j];
                    if((((sum[i] - sum[j]) | s) ^ s) < (1LL << k)) {
                        chmin(dp[i][i], dp[i][j] + 1);
                    }
                }
            }
            if(dp[n][n] > b) {
                s |= (1LL << k);
            }
        } else {
            auto dp = make_v<int>(n + 10, n + 10, n + 10);
            dp[0][0][0] = 1;
            for(int i = 1; i <= n; i++) {
                for(int j = 0; j < i; j++) {
                    for(int l = 0; l <= i; l++) {
                        dp[i][j][l] |= dp[i - 1][j][l];
                        if(l > 0 &&
                           (((sum[i] - sum[j]) | s) ^ s) < (1LL << k)) {
                            dp[i][i][l] |= dp[i][j][l - 1];
                        }
                    }
                }
            }
            bool f = false;
            for(int i = a; i <= b; i++) {
                f |= dp[n][n][i];
            }
            if(!f) {
                s |= (1LL << k);
            }
        }
    }
    cout << s << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 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 3 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 3 ms 384 KB Output is correct
10 Correct 3 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 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 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 640 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 4 ms 512 KB Output is correct
21 Correct 4 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 5 ms 512 KB Output is correct
24 Correct 4 ms 512 KB Output is correct
25 Correct 4 ms 512 KB Output is correct
26 Correct 4 ms 512 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 284 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 256 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 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 2 ms 384 KB Output is correct
5 Correct 2 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 3 ms 384 KB Output is correct
9 Correct 3 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 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 4 ms 512 KB Output is correct
21 Correct 4 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 4 ms 512 KB Output is correct
24 Correct 4 ms 512 KB Output is correct
25 Correct 4 ms 512 KB Output is correct
26 Correct 4 ms 512 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 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 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 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 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 2 ms 384 KB Output is correct
10 Correct 1 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 3 ms 512 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 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 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 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 2 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 3 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 4 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
# 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 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 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 3 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 2 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 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 4 ms 384 KB Output is correct
20 Correct 4 ms 512 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 6 ms 512 KB Output is correct
25 Correct 6 ms 512 KB Output is correct
26 Correct 4 ms 512 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 284 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 2 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 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 3 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 2 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 3 ms 384 KB Output is correct
44 Correct 6 ms 384 KB Output is correct
45 Correct 4 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 3 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 4 ms 432 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 3 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
54 Correct 3 ms 384 KB Output is correct
55 Correct 4 ms 384 KB Output is correct
56 Correct 3 ms 384 KB Output is correct
57 Correct 3 ms 384 KB Output is correct
58 Correct 3 ms 384 KB Output is correct
59 Correct 3 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 4 ms 384 KB Output is correct
62 Correct 4 ms 384 KB Output is correct
63 Correct 3 ms 384 KB Output is correct
64 Correct 181 ms 4984 KB Output is correct
65 Correct 35 ms 1452 KB Output is correct
66 Correct 75 ms 2336 KB Output is correct
67 Correct 101 ms 3608 KB Output is correct
68 Correct 183 ms 4904 KB Output is correct
69 Correct 256 ms 6132 KB Output is correct
70 Correct 190 ms 6380 KB Output is correct
71 Correct 191 ms 6136 KB Output is correct
72 Correct 245 ms 6084 KB Output is correct
73 Correct 227 ms 6280 KB Output is correct
74 Correct 296 ms 6108 KB Output is correct
# 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 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 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 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 2 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 3 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 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 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 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 4 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 3 ms 384 KB Output is correct
45 Correct 4 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 4 ms 384 KB Output is correct
48 Correct 4 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 4 ms 384 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 41 ms 1776 KB Output is correct
53 Correct 66 ms 2724 KB Output is correct
54 Correct 122 ms 4528 KB Output is correct
55 Correct 150 ms 4568 KB Output is correct
56 Correct 821 ms 16444 KB Output is correct
57 Correct 803 ms 16580 KB Output is correct
58 Correct 765 ms 16524 KB Output is correct
59 Correct 838 ms 16500 KB Output is correct
60 Correct 790 ms 16512 KB Output is correct
61 Correct 3 ms 384 KB Output is correct
62 Correct 80 ms 2728 KB Output is correct
63 Correct 174 ms 4528 KB Output is correct
64 Correct 176 ms 4684 KB Output is correct
65 Correct 369 ms 8452 KB Output is correct
66 Correct 546 ms 12816 KB Output is correct
67 Correct 712 ms 16488 KB Output is correct
68 Correct 708 ms 16660 KB Output is correct
69 Correct 752 ms 16396 KB Output is correct