Submission #846264

# Submission time Handle Problem Language Result Execution time Memory
846264 2023-09-07T13:04:08 Z vjudge1 Bali Sculptures (APIO15_sculpture) C++17
50 / 100
136 ms 600 KB
#include<bits/stdc++.h>
using namespace std;
int n,p,q,dp[2020];
long long a[2010];
bool f[110][110];

void sub1() {
    long long ans=0;
    for (int x=63;x>=0;--x) {

        f[0][0] = 1;
        memset(f,0,sizeof(f));
        long long o=ans|(1ll << x);
        for (int pos = 1 ; pos <= q ; ++pos) {
            for (int i=pos; i<=n ; ++i)
            for (int j=i ; j>=1 ; --j) {
                long long val = a[i] - a[j-1];
                f[i][pos]=(f[j-1][pos-1] && ((val & o) == 0));
            }
        }

        for (int pos=p;pos<=q;++pos)
        if (f[n][pos]) {
            ans = o;
            break;
        }
    }
    long long res = 0;
    for (int i=0;i<=63;++i)
        if ((ans&(1ll<<i)) == 0)
            res |= (1LL<<i);
    cout<<res;
}

void sub2() {
    long long ans=0;
    for (int x=63;x>=0;--x) {
        memset(dp,0x3f,sizeof(dp));
        dp[0] = 0;
        long long o = ans | (1ll << x);
        for (int i=1;i<=n;++i)
        for (int j=i;j>0;--j) {
            long long val = a[i] - a[j-1];
            if ((val & o) == 0) dp[i] = min(dp[i] , dp[j-1] + 1);
        }
        if (dp[n] <= q)
            ans=o;
    }
    long long res = 0;
    for (int i=0;i<=63;++i)
    if ((ans & (1LL<<i))==0)
        res|=(1ll<<i);
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>p>>q;
    for (int i=1;i<=n;++i)
        cin>>a[i] ,
        a[i]=a[i-1]+a[i];
    if (p != 1)
        sub1();
    else
        sub2();
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Incorrect 0 ms 344 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Incorrect 0 ms 600 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 548 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 1 ms 344 KB Output is correct
52 Correct 11 ms 344 KB Output is correct
53 Correct 18 ms 344 KB Output is correct
54 Correct 33 ms 344 KB Output is correct
55 Correct 33 ms 344 KB Output is correct
56 Correct 136 ms 344 KB Output is correct
57 Correct 131 ms 464 KB Output is correct
58 Correct 124 ms 344 KB Output is correct
59 Correct 122 ms 344 KB Output is correct
60 Correct 128 ms 456 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 21 ms 472 KB Output is correct
63 Correct 34 ms 348 KB Output is correct
64 Correct 59 ms 456 KB Output is correct
65 Correct 63 ms 460 KB Output is correct
66 Correct 105 ms 460 KB Output is correct
67 Correct 124 ms 460 KB Output is correct
68 Correct 129 ms 348 KB Output is correct
69 Correct 125 ms 460 KB Output is correct