Submission #609724

# Submission time Handle Problem Language Result Execution time Memory
609724 2022-07-27T19:53:39 Z krit3379 Bali Sculptures (APIO15_sculpture) C++17
50 / 100
560 ms 23616 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 2005

long long arr[N],qs[N][N],dp[N],bit;
bitset<N> ok[N],dpp[N];

int main(){
    int n,a,b,i,j,k,l;
    scanf("%d %d %d",&n,&a,&b);
    for(i=1;i<=n;i++)scanf("%lld",&arr[i]),arr[i]+=arr[i-1];
    for(i=1;i<=n;i++)for(j=i;j<=n;j++)qs[i][j]=arr[j]-arr[i-1];
    if(a==1){
        for(i=60;i>=0;i--){
            long long x=bit|((1ll<<i)-1ll);
            for(j=1;j<=n;j++)for(k=j;k<=n;k++)ok[j][k]=((qs[j][k]|x)==x);
            for(j=1;j<=n;j++){
                dp[j]=ok[1][j]?1:1e9;
                for(k=1;k<j;k++)if(ok[k+1][j])dp[j]=min(dp[j],dp[k]+1);
            }
            if(dp[n]>b)bit|=1ll<<i;
        }
        printf("%lld",bit);
    }
    else{
        for(i=60;i>=0;i--){
            long long x=bit|((1ll<<i)-1ll);
            for(j=1;j<=n;j++)for(k=j;k<=n;k++)ok[j][k]=((qs[j][k]|x)==x);
            for(j=1;j<=n;j++){
                for(k=1;k<=n;k++){
                    if(j==1&&ok[1][j])dpp[j][k]=true;
                    for(l=1;l<k;l++)if(dpp[j-1][l]&&ok[l+1][k])dpp[j][k]=true;
                }
            }
            for(j=a;j<=b;j++)if(dpp[j][n])break;
            if(j>b)bit|=1ll<<i;
        }
        printf("%lld",bit);
    }
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d %d",&n,&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(i=1;i<=n;i++)scanf("%lld",&arr[i]),arr[i]+=arr[i-1];
      |                      ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 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 Incorrect 0 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 356 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Incorrect 0 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 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 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 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 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 2 ms 596 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 2 ms 724 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 2 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Incorrect 0 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 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 340 KB Output is correct
15 Correct 0 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 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 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 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 596 KB Output is correct
36 Correct 4 ms 596 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
38 Correct 3 ms 724 KB Output is correct
39 Correct 2 ms 724 KB Output is correct
40 Correct 3 ms 824 KB Output is correct
41 Correct 2 ms 724 KB Output is correct
42 Correct 2 ms 724 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 724 KB Output is correct
46 Correct 2 ms 724 KB Output is correct
47 Correct 2 ms 724 KB Output is correct
48 Correct 3 ms 724 KB Output is correct
49 Correct 3 ms 724 KB Output is correct
50 Correct 2 ms 724 KB Output is correct
51 Correct 2 ms 724 KB Output is correct
52 Correct 49 ms 4060 KB Output is correct
53 Correct 81 ms 5688 KB Output is correct
54 Correct 141 ms 8480 KB Output is correct
55 Correct 144 ms 8496 KB Output is correct
56 Correct 549 ms 23508 KB Output is correct
57 Correct 522 ms 23616 KB Output is correct
58 Correct 560 ms 23488 KB Output is correct
59 Correct 500 ms 23488 KB Output is correct
60 Correct 516 ms 23508 KB Output is correct
61 Correct 2 ms 724 KB Output is correct
62 Correct 68 ms 5588 KB Output is correct
63 Correct 151 ms 8532 KB Output is correct
64 Correct 123 ms 8496 KB Output is correct
65 Correct 242 ms 14040 KB Output is correct
66 Correct 407 ms 19456 KB Output is correct
67 Correct 485 ms 23488 KB Output is correct
68 Correct 528 ms 23492 KB Output is correct
69 Correct 522 ms 23508 KB Output is correct