Submission #146451

# Submission time Handle Problem Language Result Execution time Memory
146451 2019-08-24T06:46:37 Z arnold518 Bali Sculptures (APIO15_sculpture) C++14
100 / 100
361 ms 32120 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2000;

int N, A, B;
ll Y[MAXN+10], ans=0, dp1[MAXN+10], dp2[MAXN+10][MAXN+10];

int main()
{
    int i, j, k, p;

    scanf("%d%d%d", &N, &A, &B);
    for(i=1; i<=N; i++) scanf("%lld", &Y[i]), Y[i]+=Y[i-1];

    ans=(1ll<<46)-1;
    if(A==1)
    {
        for(i=45; i>=0; i--)
        {
            ll now=1ll<<i;
            ans^=now;
            for(j=1; j<=N; j++) dp1[j]=987654321; dp1[0]=0;
            for(j=1; j<=N; j++) for(k=0; k<j; k++) if((ans|(Y[j]-Y[k]))==ans) dp1[j]=min(dp1[j], dp1[k]+1);
            if(dp1[N]>B) ans|=now;
        }
    }
    else
    {
        for(i=45; i>=0; i--)
        {
            ll now=1ll<<i;
            ans^=now;
            memset(dp2, 0, sizeof(dp2)); dp2[0][0]=1;
            for(j=1; j<=N; j++) for(k=1; k<=N; k++) for(p=0; p<j; p++) if((ans|(Y[j]-Y[p]))==ans) dp2[j][k]|=dp2[p][k-1];
            bool flag=false;
            for(j=A; j<=B; j++) flag|=dp2[N][j];
            if(!flag) ans|=now;
        }
    }
    printf("%lld", ans);
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:27:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
             for(j=1; j<=N; j++) dp1[j]=987654321; dp1[0]=0;
             ^~~
sculpture.cpp:27:51: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             for(j=1; j<=N; j++) dp1[j]=987654321; dp1[0]=0;
                                                   ^~~
sculpture.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &N, &A, &B);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:18:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%lld", &Y[i]), Y[i]+=Y[i-1];
                         ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
# 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 248 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 252 ms 32000 KB Output is correct
15 Correct 265 ms 32004 KB Output is correct
16 Correct 253 ms 31992 KB Output is correct
17 Correct 261 ms 32092 KB Output is correct
18 Correct 269 ms 32016 KB Output is correct
19 Correct 246 ms 32032 KB Output is correct
20 Correct 267 ms 32024 KB Output is correct
21 Correct 271 ms 32120 KB Output is correct
22 Correct 315 ms 31996 KB Output is correct
23 Correct 230 ms 31992 KB Output is correct
24 Correct 252 ms 31992 KB Output is correct
25 Correct 273 ms 31992 KB Output is correct
26 Correct 270 ms 31996 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 252 KB Output is correct
36 Correct 2 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 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 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 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 258 ms 31988 KB Output is correct
15 Correct 251 ms 31992 KB Output is correct
16 Correct 251 ms 31988 KB Output is correct
17 Correct 296 ms 31992 KB Output is correct
18 Correct 258 ms 31992 KB Output is correct
19 Correct 264 ms 31992 KB Output is correct
20 Correct 261 ms 31992 KB Output is correct
21 Correct 263 ms 31992 KB Output is correct
22 Correct 261 ms 31992 KB Output is correct
23 Correct 361 ms 31992 KB Output is correct
24 Correct 257 ms 31992 KB Output is correct
25 Correct 239 ms 31992 KB Output is correct
26 Correct 267 ms 31992 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 380 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 252 KB Output is correct
34 Correct 2 ms 364 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 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 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 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 368 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 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 364 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 2 ms 380 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 9 ms 376 KB Output is correct
25 Correct 3 ms 256 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 404 KB Output is correct
28 Correct 3 ms 252 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 372 KB Output is correct
2 Correct 2 ms 392 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 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 276 ms 31992 KB Output is correct
15 Correct 244 ms 32020 KB Output is correct
16 Correct 254 ms 31992 KB Output is correct
17 Correct 260 ms 31992 KB Output is correct
18 Correct 246 ms 31992 KB Output is correct
19 Correct 255 ms 32104 KB Output is correct
20 Correct 279 ms 32120 KB Output is correct
21 Correct 235 ms 31992 KB Output is correct
22 Correct 237 ms 32120 KB Output is correct
23 Correct 253 ms 31992 KB Output is correct
24 Correct 285 ms 32028 KB Output is correct
25 Correct 266 ms 31992 KB Output is correct
26 Correct 240 ms 31992 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 256 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 252 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 3 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 3 ms 376 KB Output is correct
51 Correct 3 ms 376 KB Output is correct
52 Correct 3 ms 376 KB Output is correct
53 Correct 3 ms 256 KB Output is correct
54 Correct 3 ms 376 KB Output is correct
55 Correct 3 ms 376 KB Output is correct
56 Correct 2 ms 380 KB Output is correct
57 Correct 3 ms 376 KB Output is correct
58 Correct 2 ms 376 KB Output is correct
59 Correct 3 ms 376 KB Output is correct
60 Correct 3 ms 376 KB Output is correct
61 Correct 3 ms 256 KB Output is correct
62 Correct 3 ms 376 KB Output is correct
63 Correct 3 ms 376 KB Output is correct
64 Correct 312 ms 32120 KB Output is correct
65 Correct 271 ms 31992 KB Output is correct
66 Correct 343 ms 32004 KB Output is correct
67 Correct 289 ms 32120 KB Output is correct
68 Correct 300 ms 32120 KB Output is correct
69 Correct 318 ms 31992 KB Output is correct
70 Correct 304 ms 31988 KB Output is correct
71 Correct 347 ms 31992 KB Output is correct
72 Correct 310 ms 31988 KB Output is correct
73 Correct 301 ms 32120 KB Output is correct
74 Correct 299 ms 31992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 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 2 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 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 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 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 256 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 3 ms 376 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 3 ms 380 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 380 KB Output is correct
45 Correct 3 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 3 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 256 KB Output is correct
50 Correct 3 ms 376 KB Output is correct
51 Correct 3 ms 376 KB Output is correct
52 Correct 13 ms 376 KB Output is correct
53 Correct 22 ms 376 KB Output is correct
54 Correct 37 ms 376 KB Output is correct
55 Correct 36 ms 376 KB Output is correct
56 Correct 138 ms 504 KB Output is correct
57 Correct 124 ms 376 KB Output is correct
58 Correct 124 ms 376 KB Output is correct
59 Correct 124 ms 376 KB Output is correct
60 Correct 135 ms 416 KB Output is correct
61 Correct 3 ms 376 KB Output is correct
62 Correct 24 ms 372 KB Output is correct
63 Correct 37 ms 376 KB Output is correct
64 Correct 34 ms 380 KB Output is correct
65 Correct 61 ms 376 KB Output is correct
66 Correct 94 ms 376 KB Output is correct
67 Correct 122 ms 376 KB Output is correct
68 Correct 129 ms 408 KB Output is correct
69 Correct 120 ms 412 KB Output is correct