Submission #562473

# Submission time Handle Problem Language Result Execution time Memory
562473 2022-05-14T12:40:39 Z piOOE Bali Sculptures (APIO15_sculpture) C++11
100 / 100
494 ms 832 KB
//#define _GLIBCXX_DEBUG

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//
//using namespace __gnu_pbds;
//
//template<typename T>
//using ordered_set = tree<T, null_type, less < T>, rb_tree_tag, tree_order_statistics_node_update>;

//template<typename T>
//using normal_queue = priority_queue<T, vector<T>, greater<>>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define trace(x) cout << #x << ": " << (x) << endl;
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define uniq(x) x.resize(unique(all(x)) - begin(x))
#define sz(s) ((int) size(s))
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define int128 __int128
#define pb push_back
#define popb pop_back
#define eb emplace_back
#define fi first
#define se second
#define itn int

typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;


template<typename T>
bool ckmn(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool ckmx(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

int bit(int x, int b) {
    return (x >> b) & 1;
}

int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }


const ll infL = 3e18;
const int infI = 1000000000 + 7;
const int infM = 0x3f3f3f3f; //a little bigger than 1e9
const ll infML = 0x3f3f3f3f3f3f3f3fLL; //4.5e18
const int N = 2002;
const int mod = 998244353;
const ld eps = 1e-9;
const int logn = __lg(N * 1000000000LL) + 1;

bitset<N> dp[N];

int a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, L, R;
    cin >> n >> L >> R;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    ll ans = 0;
    dp[0][0] = true;
    for (int bt = logn - 1; bt > -1; --bt) {
        for (int i = 1; i <= n; ++i) {
            dp[i] = 0;
        }
        ll x = ans;
        for (int b = bt - 1; b > -1; --b) {
            x += (1LL << b);
        }
        for (int i = 1; i <= n; ++i) {
            ll sum = 0;
            for (int j = i - 1; j > -1; --j) {
                sum += a[j + 1];
                if ((sum & x) == sum) {
                    dp[i] |= (dp[j] << 1);
                }
            }
        }
        bool ok = false;
        for (int i = L; i <= R; ++i) {
            if (dp[n][i]) {
                ok = true;
                break;
            }
        }
        if (!ok) {
            ans += (1LL << bt);
        }
    }
    cout << ans;
    return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 4 ms 340 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 4 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 4 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 5 ms 340 KB Output is correct
26 Correct 7 ms 360 KB Output is correct
27 Correct 9 ms 340 KB Output is correct
28 Correct 12 ms 360 KB Output is correct
29 Correct 11 ms 340 KB Output is correct
30 Correct 13 ms 340 KB Output is correct
31 Correct 12 ms 340 KB Output is correct
32 Correct 17 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 3 ms 340 KB Output is correct
41 Correct 4 ms 340 KB Output is correct
42 Correct 6 ms 340 KB Output is correct
43 Correct 5 ms 352 KB Output is correct
44 Correct 4 ms 340 KB Output is correct
45 Correct 3 ms 340 KB Output is correct
46 Correct 4 ms 348 KB Output is correct
47 Correct 4 ms 340 KB Output is correct
48 Correct 5 ms 340 KB Output is correct
49 Correct 7 ms 340 KB Output is correct
50 Correct 9 ms 340 KB Output is correct
51 Correct 12 ms 340 KB Output is correct
52 Correct 11 ms 340 KB Output is correct
53 Correct 12 ms 340 KB Output is correct
54 Correct 13 ms 368 KB Output is correct
55 Correct 12 ms 340 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 3 ms 340 KB Output is correct
58 Correct 3 ms 340 KB Output is correct
59 Correct 3 ms 340 KB Output is correct
60 Correct 3 ms 340 KB Output is correct
61 Correct 3 ms 340 KB Output is correct
62 Correct 4 ms 340 KB Output is correct
63 Correct 4 ms 360 KB Output is correct
64 Correct 10 ms 340 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 2 ms 340 KB Output is correct
67 Correct 2 ms 340 KB Output is correct
68 Correct 3 ms 360 KB Output is correct
69 Correct 3 ms 340 KB Output is correct
70 Correct 3 ms 340 KB Output is correct
71 Correct 3 ms 340 KB Output is correct
72 Correct 5 ms 340 KB Output is correct
73 Correct 6 ms 340 KB Output is correct
74 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 4 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 4 ms 340 KB Output is correct
35 Correct 6 ms 352 KB Output is correct
36 Correct 8 ms 356 KB Output is correct
37 Correct 10 ms 356 KB Output is correct
38 Correct 14 ms 364 KB Output is correct
39 Correct 11 ms 340 KB Output is correct
40 Correct 11 ms 360 KB Output is correct
41 Correct 11 ms 360 KB Output is correct
42 Correct 16 ms 356 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 3 ms 352 KB Output is correct
45 Correct 3 ms 340 KB Output is correct
46 Correct 3 ms 340 KB Output is correct
47 Correct 3 ms 340 KB Output is correct
48 Correct 3 ms 340 KB Output is correct
49 Correct 5 ms 340 KB Output is correct
50 Correct 6 ms 340 KB Output is correct
51 Correct 5 ms 340 KB Output is correct
52 Correct 76 ms 468 KB Output is correct
53 Correct 83 ms 508 KB Output is correct
54 Correct 154 ms 568 KB Output is correct
55 Correct 150 ms 468 KB Output is correct
56 Correct 452 ms 824 KB Output is correct
57 Correct 421 ms 820 KB Output is correct
58 Correct 290 ms 820 KB Output is correct
59 Correct 320 ms 820 KB Output is correct
60 Correct 494 ms 820 KB Output is correct
61 Correct 5 ms 340 KB Output is correct
62 Correct 95 ms 468 KB Output is correct
63 Correct 147 ms 468 KB Output is correct
64 Correct 136 ms 572 KB Output is correct
65 Correct 234 ms 676 KB Output is correct
66 Correct 291 ms 756 KB Output is correct
67 Correct 406 ms 832 KB Output is correct
68 Correct 474 ms 816 KB Output is correct
69 Correct 360 ms 820 KB Output is correct