Submission #170866

# Submission time Handle Problem Language Result Execution time Memory
170866 2019-12-26T15:52:51 Z ne4eHbKa Bali Sculptures (APIO15_sculpture) C++17
25 / 100
1000 ms 504 KB
//{ <defines>
#ifndef _LOCAL
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#endif

#include <bits/stdc++.h>
using namespace std;

#define fr(i, n) for(int i = 0; i < n; ++i)
#define fo(n) fr(i, n)

#define re return
#define ef else if
#define ifn(x) if(!(x))
#define _  << ' ' <<

#define ft first
#define sd second
#define ve vector
#define pb push_back
#define eb emplace_back

#define sz(x) int(x.size())
#define pw(x) (1 << (x))
#define PW(x) (1ll << (x))
#define bnd(x) x.begin(), x.end()
#define clr(x, y) memset(x, y, sizeof x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef ve<int> vi;

const int oo = 2e9;
const ll OO = 4e18;
//const ld pi = arg(complex<ld>(-1, 0));
//const ld pi2 = pi + pi;
const int md = 0x3b800001;
const int MD = 1e9 + 7;

inline ll time() {re chrono :: system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
mt19937_64 RND(time());

template<typename t> inline void umin(t &a, t b) {a = min(a, b);}
template<typename t> inline void umax(t &a, t b) {a = max(a, b);}
//} </defines>
const int N = 2e5 + 228;

void solve() {
    int n, a, b; cin >> n >> a >> b;
    ll y[n]; fo(n) cin >> y[i];

    int g[n + 1][n]; clr(g, 0); int e[n + 1];
    int q[n]; int m;

    ll ans = OO;

    for(int x = a; x <= b; ++x) {
        ll f = 0;

        for(char bt = 38; ~bt; --bt) {
            bool fail = false;

            clr(e, 0);
            for(int l = 0; l < n; ++l) {
                ll sum = 0;
                for(int r = l; r < n; ++r) {
                    sum += y[r];
                    if((sum & ~f) < PW(bt)) g[l][e[l]++] = r + 1;
                }
            }

            m = 1; q[0] = 0;
            fo(x) {
                if(!m) { fail = true; break; }
                set<int> h;
                for(int v = 0; v < m; ++v)
                    for(int u = 0; u < e[q[v]]; ++u) h.insert(g[q[v]][u]);
                m = 0; for(int v : h) q[m++] = v;
            }

            if(!m || q[m - 1] != n) fail = true;

            if(fail) f ^= PW(bt);
        }

        umin(ans, f);
    }

    cout << ans << endl;
}

int main() {
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 12 ms 400 KB Output is correct
14 Correct 2 ms 480 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 380 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 4 ms 376 KB Output is correct
26 Correct 8 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 252 KB Output is correct
33 Correct 6 ms 256 KB Output is correct
34 Correct 11 ms 256 KB Output is correct
35 Correct 2 ms 256 KB Output is correct
36 Correct 11 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 12 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 4 ms 256 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 4 ms 256 KB Output is correct
26 Correct 8 ms 256 KB Output is correct
27 Correct 16 ms 376 KB Output is correct
28 Correct 9 ms 256 KB Output is correct
29 Correct 6 ms 256 KB Output is correct
30 Correct 59 ms 376 KB Output is correct
31 Correct 97 ms 376 KB Output is correct
32 Correct 96 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 100 ms 376 KB Output is correct
35 Correct 75 ms 372 KB Output is correct
36 Correct 31 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 7 ms 476 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 12 ms 376 KB Output is correct
14 Correct 17 ms 376 KB Output is correct
15 Correct 9 ms 256 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 59 ms 256 KB Output is correct
18 Correct 98 ms 368 KB Output is correct
19 Correct 96 ms 476 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 100 ms 476 KB Output is correct
22 Correct 75 ms 376 KB Output is correct
23 Correct 30 ms 376 KB Output is correct
24 Correct 101 ms 376 KB Output is correct
25 Correct 49 ms 384 KB Output is correct
26 Correct 316 ms 504 KB Output is correct
27 Execution timed out 1074 ms 376 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 12 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 376 KB Output is correct
22 Correct 4 ms 376 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 2 ms 252 KB Output is correct
25 Correct 4 ms 376 KB Output is correct
26 Correct 8 ms 256 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 3 ms 252 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 10 ms 256 KB Output is correct
35 Correct 2 ms 256 KB Output is correct
36 Correct 11 ms 256 KB Output is correct
37 Correct 16 ms 360 KB Output is correct
38 Correct 9 ms 256 KB Output is correct
39 Correct 6 ms 280 KB Output is correct
40 Correct 59 ms 504 KB Output is correct
41 Correct 97 ms 368 KB Output is correct
42 Correct 96 ms 372 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 102 ms 376 KB Output is correct
45 Correct 78 ms 376 KB Output is correct
46 Correct 30 ms 256 KB Output is correct
47 Correct 103 ms 408 KB Output is correct
48 Correct 48 ms 376 KB Output is correct
49 Correct 315 ms 376 KB Output is correct
50 Execution timed out 1078 ms 376 KB Time limit exceeded
51 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 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 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 12 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 3 ms 252 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 10 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 19 ms 376 KB Output is correct
24 Correct 16 ms 252 KB Output is correct
25 Correct 9 ms 256 KB Output is correct
26 Correct 6 ms 256 KB Output is correct
27 Correct 59 ms 256 KB Output is correct
28 Correct 98 ms 368 KB Output is correct
29 Correct 96 ms 368 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 100 ms 376 KB Output is correct
32 Correct 75 ms 256 KB Output is correct
33 Correct 30 ms 376 KB Output is correct
34 Correct 101 ms 380 KB Output is correct
35 Correct 48 ms 376 KB Output is correct
36 Correct 315 ms 504 KB Output is correct
37 Execution timed out 1076 ms 376 KB Time limit exceeded
38 Halted 0 ms 0 KB -