Submission #31401

# Submission time Handle Problem Language Result Execution time Memory
31401 2017-08-21T06:47:58 Z nickyrio Bali Sculptures (APIO15_sculpture) C++14
100 / 100
266 ms 6192 KB
#include <bits/stdc++.h>
#define N 2020
#define FOR(i, a, b) for (int i = a; i<=b; i++)
#define FORD(i, a, b) for (int i = a; i>=b; i--)
#define REP(i, a) for (int i = 1; i<=a; i++)

using namespace std;

int f[N], c[N], n, a, b;
long long s[N];
bool g[N][N];

const int inf = 1e9;

bool solve1(int k, long long limit) { // N^2 && a == 1
    REP(i, n) f[i] = inf;
    f[0] = 0;
    REP(i, n) FOR(j, 1, i)
        if ((((s[i] - s[j - 1]) | limit) >> k) == (limit >> k)) {
        f[i] = min(f[i], f[j - 1] + 1);
    }
    return f[n] <=b;
}

bool solve2(int k, long long limit) { //N^3 && a > 1
    FOR(i, 0, n) REP(j, n) g[i][j] = false;
    g[0][0] = true;
    FOR(kk, 1, b)
        FOR(j, 1, n)
            FOR(i, j, n) {
        if (((((s[i] - s[j - 1]) | limit) >> k) == (limit >> k)) && g[kk - 1][j - 1])
            g[kk][i] = true;
    }
    FOR(i, a, b) if (g[i][n]) return true;
    return false;
}

bool ok(int k, long long limit) {
    if (a == 1) return solve1(k, limit);
    return solve2(k, limit);
}

int main() {
    //freopen("SCULPTURE.inp","r",stdin);
    //freopen("SCULPTURE.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin>>n>>a>>b;
    REP(i, n) cin>>c[i];
    long long ans = 0;
    FOR(i, 1, n) s[i] = c[i] + s[i - 1];
    FORD(k, 62, 0) {
        if (!ok(k, ans))
            ans |= (1ll << k);
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6192 KB Output is correct
2 Correct 0 ms 6192 KB Output is correct
3 Correct 0 ms 6192 KB Output is correct
4 Correct 0 ms 6192 KB Output is correct
5 Correct 0 ms 6192 KB Output is correct
6 Correct 0 ms 6192 KB Output is correct
7 Correct 0 ms 6192 KB Output is correct
8 Correct 0 ms 6192 KB Output is correct
9 Correct 0 ms 6192 KB Output is correct
10 Correct 0 ms 6192 KB Output is correct
11 Correct 0 ms 6192 KB Output is correct
12 Correct 0 ms 6192 KB Output is correct
13 Correct 0 ms 6192 KB Output is correct
14 Correct 0 ms 6192 KB Output is correct
15 Correct 0 ms 6192 KB Output is correct
16 Correct 0 ms 6192 KB Output is correct
17 Correct 0 ms 6192 KB Output is correct
18 Correct 0 ms 6192 KB Output is correct
19 Correct 0 ms 6192 KB Output is correct
20 Correct 0 ms 6192 KB Output is correct
21 Correct 0 ms 6192 KB Output is correct
22 Correct 0 ms 6192 KB Output is correct
23 Correct 0 ms 6192 KB Output is correct
24 Correct 0 ms 6192 KB Output is correct
25 Correct 0 ms 6192 KB Output is correct
26 Correct 0 ms 6192 KB Output is correct
27 Correct 0 ms 6192 KB Output is correct
28 Correct 0 ms 6192 KB Output is correct
29 Correct 0 ms 6192 KB Output is correct
30 Correct 0 ms 6192 KB Output is correct
31 Correct 0 ms 6192 KB Output is correct
32 Correct 0 ms 6192 KB Output is correct
33 Correct 0 ms 6192 KB Output is correct
34 Correct 0 ms 6192 KB Output is correct
35 Correct 0 ms 6192 KB Output is correct
36 Correct 0 ms 6192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6192 KB Output is correct
2 Correct 0 ms 6192 KB Output is correct
3 Correct 0 ms 6192 KB Output is correct
4 Correct 0 ms 6192 KB Output is correct
5 Correct 0 ms 6192 KB Output is correct
6 Correct 0 ms 6192 KB Output is correct
7 Correct 0 ms 6192 KB Output is correct
8 Correct 0 ms 6192 KB Output is correct
9 Correct 0 ms 6192 KB Output is correct
10 Correct 0 ms 6192 KB Output is correct
11 Correct 0 ms 6192 KB Output is correct
12 Correct 0 ms 6192 KB Output is correct
13 Correct 0 ms 6192 KB Output is correct
14 Correct 0 ms 6192 KB Output is correct
15 Correct 0 ms 6192 KB Output is correct
16 Correct 0 ms 6192 KB Output is correct
17 Correct 0 ms 6192 KB Output is correct
18 Correct 0 ms 6192 KB Output is correct
19 Correct 0 ms 6192 KB Output is correct
20 Correct 0 ms 6192 KB Output is correct
21 Correct 0 ms 6192 KB Output is correct
22 Correct 0 ms 6192 KB Output is correct
23 Correct 0 ms 6192 KB Output is correct
24 Correct 0 ms 6192 KB Output is correct
25 Correct 0 ms 6192 KB Output is correct
26 Correct 0 ms 6192 KB Output is correct
27 Correct 0 ms 6192 KB Output is correct
28 Correct 0 ms 6192 KB Output is correct
29 Correct 0 ms 6192 KB Output is correct
30 Correct 0 ms 6192 KB Output is correct
31 Correct 0 ms 6192 KB Output is correct
32 Correct 0 ms 6192 KB Output is correct
33 Correct 0 ms 6192 KB Output is correct
34 Correct 0 ms 6192 KB Output is correct
35 Correct 0 ms 6192 KB Output is correct
36 Correct 0 ms 6192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6192 KB Output is correct
2 Correct 0 ms 6192 KB Output is correct
3 Correct 0 ms 6192 KB Output is correct
4 Correct 0 ms 6192 KB Output is correct
5 Correct 0 ms 6192 KB Output is correct
6 Correct 0 ms 6192 KB Output is correct
7 Correct 0 ms 6192 KB Output is correct
8 Correct 0 ms 6192 KB Output is correct
9 Correct 0 ms 6192 KB Output is correct
10 Correct 0 ms 6192 KB Output is correct
11 Correct 0 ms 6192 KB Output is correct
12 Correct 0 ms 6192 KB Output is correct
13 Correct 0 ms 6192 KB Output is correct
14 Correct 0 ms 6192 KB Output is correct
15 Correct 0 ms 6192 KB Output is correct
16 Correct 0 ms 6192 KB Output is correct
17 Correct 0 ms 6192 KB Output is correct
18 Correct 0 ms 6192 KB Output is correct
19 Correct 0 ms 6192 KB Output is correct
20 Correct 0 ms 6192 KB Output is correct
21 Correct 0 ms 6192 KB Output is correct
22 Correct 0 ms 6192 KB Output is correct
23 Correct 0 ms 6192 KB Output is correct
24 Correct 0 ms 6192 KB Output is correct
25 Correct 0 ms 6192 KB Output is correct
26 Correct 0 ms 6192 KB Output is correct
27 Correct 0 ms 6192 KB Output is correct
28 Correct 0 ms 6192 KB Output is correct
29 Correct 0 ms 6192 KB Output is correct
30 Correct 0 ms 6192 KB Output is correct
31 Correct 0 ms 6192 KB Output is correct
32 Correct 0 ms 6192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6192 KB Output is correct
2 Correct 0 ms 6192 KB Output is correct
3 Correct 0 ms 6192 KB Output is correct
4 Correct 0 ms 6192 KB Output is correct
5 Correct 0 ms 6192 KB Output is correct
6 Correct 0 ms 6192 KB Output is correct
7 Correct 0 ms 6192 KB Output is correct
8 Correct 0 ms 6192 KB Output is correct
9 Correct 0 ms 6192 KB Output is correct
10 Correct 0 ms 6192 KB Output is correct
11 Correct 0 ms 6192 KB Output is correct
12 Correct 0 ms 6192 KB Output is correct
13 Correct 0 ms 6192 KB Output is correct
14 Correct 0 ms 6192 KB Output is correct
15 Correct 0 ms 6192 KB Output is correct
16 Correct 0 ms 6192 KB Output is correct
17 Correct 0 ms 6192 KB Output is correct
18 Correct 0 ms 6192 KB Output is correct
19 Correct 0 ms 6192 KB Output is correct
20 Correct 0 ms 6192 KB Output is correct
21 Correct 0 ms 6192 KB Output is correct
22 Correct 0 ms 6192 KB Output is correct
23 Correct 0 ms 6192 KB Output is correct
24 Correct 0 ms 6192 KB Output is correct
25 Correct 0 ms 6192 KB Output is correct
26 Correct 0 ms 6192 KB Output is correct
27 Correct 0 ms 6192 KB Output is correct
28 Correct 0 ms 6192 KB Output is correct
29 Correct 0 ms 6192 KB Output is correct
30 Correct 0 ms 6192 KB Output is correct
31 Correct 0 ms 6192 KB Output is correct
32 Correct 0 ms 6192 KB Output is correct
33 Correct 0 ms 6192 KB Output is correct
34 Correct 0 ms 6192 KB Output is correct
35 Correct 0 ms 6192 KB Output is correct
36 Correct 0 ms 6192 KB Output is correct
37 Correct 0 ms 6192 KB Output is correct
38 Correct 0 ms 6192 KB Output is correct
39 Correct 0 ms 6192 KB Output is correct
40 Correct 0 ms 6192 KB Output is correct
41 Correct 0 ms 6192 KB Output is correct
42 Correct 0 ms 6192 KB Output is correct
43 Correct 0 ms 6192 KB Output is correct
44 Correct 0 ms 6192 KB Output is correct
45 Correct 0 ms 6192 KB Output is correct
46 Correct 0 ms 6192 KB Output is correct
47 Correct 0 ms 6192 KB Output is correct
48 Correct 0 ms 6192 KB Output is correct
49 Correct 0 ms 6192 KB Output is correct
50 Correct 0 ms 6192 KB Output is correct
51 Correct 0 ms 6192 KB Output is correct
52 Correct 0 ms 6192 KB Output is correct
53 Correct 0 ms 6192 KB Output is correct
54 Correct 0 ms 6192 KB Output is correct
55 Correct 0 ms 6192 KB Output is correct
56 Correct 0 ms 6192 KB Output is correct
57 Correct 0 ms 6192 KB Output is correct
58 Correct 0 ms 6192 KB Output is correct
59 Correct 0 ms 6192 KB Output is correct
60 Correct 0 ms 6192 KB Output is correct
61 Correct 0 ms 6192 KB Output is correct
62 Correct 0 ms 6192 KB Output is correct
63 Correct 0 ms 6192 KB Output is correct
64 Correct 43 ms 6192 KB Output is correct
65 Correct 3 ms 6192 KB Output is correct
66 Correct 3 ms 6192 KB Output is correct
67 Correct 9 ms 6192 KB Output is correct
68 Correct 26 ms 6192 KB Output is correct
69 Correct 53 ms 6192 KB Output is correct
70 Correct 53 ms 6192 KB Output is correct
71 Correct 0 ms 6192 KB Output is correct
72 Correct 59 ms 6192 KB Output is correct
73 Correct 39 ms 6192 KB Output is correct
74 Correct 33 ms 6192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6192 KB Output is correct
2 Correct 0 ms 6192 KB Output is correct
3 Correct 0 ms 6192 KB Output is correct
4 Correct 0 ms 6192 KB Output is correct
5 Correct 0 ms 6192 KB Output is correct
6 Correct 0 ms 6192 KB Output is correct
7 Correct 0 ms 6192 KB Output is correct
8 Correct 0 ms 6192 KB Output is correct
9 Correct 0 ms 6192 KB Output is correct
10 Correct 0 ms 6192 KB Output is correct
11 Correct 0 ms 6192 KB Output is correct
12 Correct 0 ms 6192 KB Output is correct
13 Correct 0 ms 6192 KB Output is correct
14 Correct 0 ms 6192 KB Output is correct
15 Correct 0 ms 6192 KB Output is correct
16 Correct 0 ms 6192 KB Output is correct
17 Correct 0 ms 6192 KB Output is correct
18 Correct 0 ms 6192 KB Output is correct
19 Correct 0 ms 6192 KB Output is correct
20 Correct 0 ms 6192 KB Output is correct
21 Correct 0 ms 6192 KB Output is correct
22 Correct 0 ms 6192 KB Output is correct
23 Correct 0 ms 6192 KB Output is correct
24 Correct 0 ms 6192 KB Output is correct
25 Correct 0 ms 6192 KB Output is correct
26 Correct 0 ms 6192 KB Output is correct
27 Correct 0 ms 6192 KB Output is correct
28 Correct 0 ms 6192 KB Output is correct
29 Correct 0 ms 6192 KB Output is correct
30 Correct 0 ms 6192 KB Output is correct
31 Correct 0 ms 6192 KB Output is correct
32 Correct 0 ms 6192 KB Output is correct
33 Correct 0 ms 6192 KB Output is correct
34 Correct 0 ms 6192 KB Output is correct
35 Correct 0 ms 6192 KB Output is correct
36 Correct 0 ms 6192 KB Output is correct
37 Correct 0 ms 6192 KB Output is correct
38 Correct 0 ms 6192 KB Output is correct
39 Correct 0 ms 6192 KB Output is correct
40 Correct 0 ms 6192 KB Output is correct
41 Correct 0 ms 6192 KB Output is correct
42 Correct 0 ms 6192 KB Output is correct
43 Correct 0 ms 6192 KB Output is correct
44 Correct 0 ms 6192 KB Output is correct
45 Correct 0 ms 6192 KB Output is correct
46 Correct 0 ms 6192 KB Output is correct
47 Correct 0 ms 6192 KB Output is correct
48 Correct 0 ms 6192 KB Output is correct
49 Correct 0 ms 6192 KB Output is correct
50 Correct 0 ms 6192 KB Output is correct
51 Correct 0 ms 6192 KB Output is correct
52 Correct 26 ms 6192 KB Output is correct
53 Correct 43 ms 6192 KB Output is correct
54 Correct 66 ms 6192 KB Output is correct
55 Correct 63 ms 6192 KB Output is correct
56 Correct 246 ms 6192 KB Output is correct
57 Correct 266 ms 6192 KB Output is correct
58 Correct 243 ms 6192 KB Output is correct
59 Correct 243 ms 6192 KB Output is correct
60 Correct 256 ms 6192 KB Output is correct
61 Correct 0 ms 6192 KB Output is correct
62 Correct 36 ms 6192 KB Output is correct
63 Correct 66 ms 6192 KB Output is correct
64 Correct 63 ms 6192 KB Output is correct
65 Correct 126 ms 6192 KB Output is correct
66 Correct 199 ms 6192 KB Output is correct
67 Correct 253 ms 6192 KB Output is correct
68 Correct 256 ms 6192 KB Output is correct
69 Correct 249 ms 6192 KB Output is correct