Submission #721890

# Submission time Handle Problem Language Result Execution time Memory
721890 2023-04-11T08:28:45 Z n0sk1ll Bali Sculptures (APIO15_sculpture) C++14
100 / 100
154 ms 468 KB
#include <bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)

using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;







//Note to self: Check for overflow

li a[2006];
li pre[2006];

bool mz[103][103];

li brute(int n, int A, int B)
{
    li ans=0;

    li include=0;
    bff(b,0,50)
    {
        li cur=include|(1ll<<b);
        fff(k,0,n) fff(i,1,n) mz[k][i]=0;
        mz[0][n+1]=1;

        fff(k,1,n) fff(i,1,n) fff(j,i,n)
            if (!((pre[j]-pre[i-1])&cur)) mz[k][i]|=mz[k-1][j+1];

        bool los=true;
        fff(k,A,B) if (mz[k][1]) los=false;

        if (los) ans|=(1ll<<b);
        else include=cur;
    }

    return ans;
}

int dp[2006];

int main()
{
    FAST;

    int n,A,B; cin>>n>>A>>B;
    fff(i,1,n) cin>>a[i];
    fff(i,1,n) pre[i]=pre[i-1]+a[i];

    if (n<=100) return cout<<brute(n,A,B),0;

    int k=B;
    li ans=0;

    li include=0;
    bff(b,0,50)
    {
        li cur=include|(1ll<<b);
        fff(i,1,n) dp[i]=mod;
        dp[n+1]=0;

        bfff(i,1,n)
        {
            li tmp=0;
            fff(j,i,n)
            {
                tmp+=a[j];
                if (!(tmp&cur)) dp[i]=min(dp[i],dp[j+1]+1);
            }
        }

        if (dp[1]>k) ans|=(1ll<<b);
        else include=cur;
    }

    cout<<ans<<"\n";
}

//Note to self: Check for overflow

/*

6 1 3
8 1 2 1 5 4

10 1 10
1 1 1 1 1 1 1 1 1 1

*/
# 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 324 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 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 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 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 324 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 212 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 328 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 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 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 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 340 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 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 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 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 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 328 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 212 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 2 ms 328 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 7 ms 324 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 324 KB Output is correct
34 Correct 6 ms 340 KB Output is correct
35 Correct 6 ms 332 KB Output is correct
36 Correct 6 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 332 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 340 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 236 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 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 5 ms 344 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 6 ms 340 KB Output is correct
22 Correct 6 ms 340 KB Output is correct
23 Correct 5 ms 336 KB Output is correct
24 Correct 6 ms 340 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
26 Correct 23 ms 344 KB Output is correct
27 Correct 38 ms 340 KB Output is correct
28 Correct 42 ms 340 KB Output is correct
29 Correct 47 ms 340 KB Output is correct
30 Correct 44 ms 340 KB Output is correct
31 Correct 47 ms 340 KB Output is correct
32 Correct 49 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 212 KB Output is correct
4 Correct 0 ms 340 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 212 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 212 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 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 324 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 332 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 328 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 328 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 2 ms 340 KB Output is correct
39 Correct 4 ms 340 KB Output is correct
40 Correct 3 ms 340 KB Output is correct
41 Correct 5 ms 340 KB Output is correct
42 Correct 7 ms 328 KB Output is correct
43 Correct 5 ms 348 KB Output is correct
44 Correct 7 ms 340 KB Output is correct
45 Correct 5 ms 324 KB Output is correct
46 Correct 7 ms 340 KB Output is correct
47 Correct 6 ms 340 KB Output is correct
48 Correct 11 ms 340 KB Output is correct
49 Correct 24 ms 340 KB Output is correct
50 Correct 34 ms 328 KB Output is correct
51 Correct 43 ms 340 KB Output is correct
52 Correct 49 ms 328 KB Output is correct
53 Correct 46 ms 344 KB Output is correct
54 Correct 43 ms 340 KB Output is correct
55 Correct 48 ms 340 KB Output is correct
56 Correct 7 ms 340 KB Output is correct
57 Correct 18 ms 340 KB Output is correct
58 Correct 25 ms 348 KB Output is correct
59 Correct 36 ms 340 KB Output is correct
60 Correct 35 ms 340 KB Output is correct
61 Correct 38 ms 340 KB Output is correct
62 Correct 40 ms 340 KB Output is correct
63 Correct 40 ms 340 KB Output is correct
64 Correct 34 ms 336 KB Output is correct
65 Correct 6 ms 340 KB Output is correct
66 Correct 12 ms 468 KB Output is correct
67 Correct 17 ms 340 KB Output is correct
68 Correct 27 ms 340 KB Output is correct
69 Correct 35 ms 340 KB Output is correct
70 Correct 32 ms 340 KB Output is correct
71 Correct 37 ms 348 KB Output is correct
72 Correct 38 ms 332 KB Output is correct
73 Correct 38 ms 340 KB Output is correct
74 Correct 38 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 212 KB Output is correct
7 Correct 1 ms 212 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 212 KB Output is correct
11 Correct 1 ms 212 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 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 4 ms 340 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 5 ms 340 KB Output is correct
30 Correct 6 ms 340 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 15 ms 344 KB Output is correct
36 Correct 20 ms 348 KB Output is correct
37 Correct 32 ms 340 KB Output is correct
38 Correct 51 ms 340 KB Output is correct
39 Correct 44 ms 340 KB Output is correct
40 Correct 45 ms 340 KB Output is correct
41 Correct 50 ms 340 KB Output is correct
42 Correct 44 ms 344 KB Output is correct
43 Correct 6 ms 340 KB Output is correct
44 Correct 22 ms 344 KB Output is correct
45 Correct 37 ms 340 KB Output is correct
46 Correct 36 ms 340 KB Output is correct
47 Correct 33 ms 340 KB Output is correct
48 Correct 33 ms 348 KB Output is correct
49 Correct 38 ms 340 KB Output is correct
50 Correct 38 ms 348 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 14 ms 348 KB Output is correct
53 Correct 22 ms 340 KB Output is correct
54 Correct 42 ms 340 KB Output is correct
55 Correct 42 ms 340 KB Output is correct
56 Correct 137 ms 360 KB Output is correct
57 Correct 150 ms 348 KB Output is correct
58 Correct 154 ms 348 KB Output is correct
59 Correct 136 ms 348 KB Output is correct
60 Correct 138 ms 344 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 23 ms 352 KB Output is correct
63 Correct 39 ms 340 KB Output is correct
64 Correct 39 ms 344 KB Output is correct
65 Correct 82 ms 340 KB Output is correct
66 Correct 101 ms 352 KB Output is correct
67 Correct 133 ms 348 KB Output is correct
68 Correct 150 ms 352 KB Output is correct
69 Correct 135 ms 348 KB Output is correct