Submission #219965

# Submission time Handle Problem Language Result Execution time Memory
219965 2020-04-06T18:09:41 Z MKopchev Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 4608 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=2e3+42;
int n,a,b,inp[nmax];
long long pref[nmax];

long long current;

bool possible;

bool been[nmax][nmax];

void dfs(int groups,int last_end)
{
    if(possible)return;
    if(groups>b)return;

    if(last_end==n)
    {
        if(groups>=a)possible=1;
        return;
    }

    if(been[groups][last_end])return;
    been[groups][last_end]=1;

    if(((pref[n]-pref[last_end])&current)==(pref[n]-pref[last_end]))dfs(groups+1,n);

    for(int j=last_end+1;j<n;j++)
    {
        long long sum=pref[j]-pref[last_end];
        if((current&sum)==sum)dfs(groups+1,j);
    }
}
bool can(long long to_test)
{
    current=to_test;

    memset(been,0,sizeof(been));

    possible=0;

    dfs(0,0);

    return possible;
}
int main()
{
    scanf("%i%i%i",&n,&a,&b);
    for(int i=1;i<=n;i++)scanf("%i",&inp[i]);

    for(int i=1;i<=n;i++)pref[i]=pref[i-1]+inp[i];

    long long output=(1LL<<41)-1;

    for(int i=40;i>=0;i--)
        if(can(output-(1LL<<i)))output=output-(1LL<<i);

    printf("%lld\n",output);
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i",&n,&a,&b);
     ~~~~~^~~~~~~~~~~~~~~~~~~
sculpture.cpp:50:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++)scanf("%i",&inp[i]);
                          ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 4352 KB Output is correct
2 Correct 11 ms 4352 KB Output is correct
3 Correct 11 ms 4352 KB Output is correct
4 Correct 12 ms 4532 KB Output is correct
5 Correct 12 ms 4452 KB Output is correct
6 Correct 11 ms 4352 KB Output is correct
7 Correct 11 ms 4352 KB Output is correct
8 Correct 11 ms 4352 KB Output is correct
9 Correct 11 ms 4352 KB Output is correct
10 Correct 12 ms 4352 KB Output is correct
11 Correct 12 ms 4480 KB Output is correct
12 Correct 12 ms 4352 KB Output is correct
13 Correct 11 ms 4352 KB Output is correct
14 Correct 12 ms 4480 KB Output is correct
15 Correct 12 ms 4352 KB Output is correct
16 Correct 12 ms 4352 KB Output is correct
17 Correct 11 ms 4480 KB Output is correct
18 Correct 12 ms 4480 KB Output is correct
19 Correct 12 ms 4352 KB Output is correct
20 Correct 12 ms 4352 KB Output is correct
21 Correct 11 ms 4352 KB Output is correct
22 Correct 11 ms 4352 KB Output is correct
23 Correct 12 ms 4352 KB Output is correct
24 Correct 16 ms 4352 KB Output is correct
25 Correct 12 ms 4352 KB Output is correct
26 Correct 11 ms 4352 KB Output is correct
27 Correct 11 ms 4352 KB Output is correct
28 Correct 12 ms 4480 KB Output is correct
29 Correct 12 ms 4480 KB Output is correct
30 Correct 11 ms 4352 KB Output is correct
31 Correct 11 ms 4352 KB Output is correct
32 Correct 11 ms 4352 KB Output is correct
33 Correct 11 ms 4352 KB Output is correct
34 Correct 12 ms 4352 KB Output is correct
35 Correct 11 ms 4352 KB Output is correct
36 Correct 11 ms 4480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4352 KB Output is correct
2 Correct 11 ms 4352 KB Output is correct
3 Correct 11 ms 4352 KB Output is correct
4 Correct 11 ms 4480 KB Output is correct
5 Correct 11 ms 4480 KB Output is correct
6 Correct 11 ms 4352 KB Output is correct
7 Correct 15 ms 4480 KB Output is correct
8 Correct 12 ms 4352 KB Output is correct
9 Correct 12 ms 4352 KB Output is correct
10 Correct 11 ms 4480 KB Output is correct
11 Correct 11 ms 4352 KB Output is correct
12 Correct 12 ms 4352 KB Output is correct
13 Correct 12 ms 4352 KB Output is correct
14 Correct 12 ms 4352 KB Output is correct
15 Correct 11 ms 4352 KB Output is correct
16 Correct 12 ms 4352 KB Output is correct
17 Correct 11 ms 4480 KB Output is correct
18 Correct 12 ms 4352 KB Output is correct
19 Correct 12 ms 4352 KB Output is correct
20 Correct 11 ms 4352 KB Output is correct
21 Correct 12 ms 4352 KB Output is correct
22 Correct 12 ms 4352 KB Output is correct
23 Correct 11 ms 4352 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 12 ms 4352 KB Output is correct
26 Correct 17 ms 4480 KB Output is correct
27 Correct 12 ms 4480 KB Output is correct
28 Correct 11 ms 4352 KB Output is correct
29 Correct 11 ms 4352 KB Output is correct
30 Correct 12 ms 4352 KB Output is correct
31 Correct 12 ms 4352 KB Output is correct
32 Correct 13 ms 4480 KB Output is correct
33 Correct 12 ms 4352 KB Output is correct
34 Correct 11 ms 4480 KB Output is correct
35 Correct 14 ms 4352 KB Output is correct
36 Correct 11 ms 4352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 4480 KB Output is correct
2 Correct 11 ms 4352 KB Output is correct
3 Correct 12 ms 4352 KB Output is correct
4 Correct 11 ms 4352 KB Output is correct
5 Correct 12 ms 4352 KB Output is correct
6 Correct 11 ms 4352 KB Output is correct
7 Correct 11 ms 4352 KB Output is correct
8 Correct 12 ms 4352 KB Output is correct
9 Correct 12 ms 4352 KB Output is correct
10 Correct 11 ms 4352 KB Output is correct
11 Correct 12 ms 4352 KB Output is correct
12 Correct 11 ms 4352 KB Output is correct
13 Correct 12 ms 4352 KB Output is correct
14 Correct 11 ms 4352 KB Output is correct
15 Correct 14 ms 4352 KB Output is correct
16 Correct 11 ms 4352 KB Output is correct
17 Correct 12 ms 4480 KB Output is correct
18 Correct 12 ms 4352 KB Output is correct
19 Correct 12 ms 4352 KB Output is correct
20 Correct 12 ms 4352 KB Output is correct
21 Correct 13 ms 4480 KB Output is correct
22 Correct 12 ms 4480 KB Output is correct
23 Correct 12 ms 4480 KB Output is correct
24 Correct 12 ms 4352 KB Output is correct
25 Correct 12 ms 4480 KB Output is correct
26 Correct 11 ms 4352 KB Output is correct
27 Correct 11 ms 4352 KB Output is correct
28 Correct 12 ms 4352 KB Output is correct
29 Correct 12 ms 4352 KB Output is correct
30 Correct 11 ms 4352 KB Output is correct
31 Correct 12 ms 4352 KB Output is correct
32 Correct 15 ms 4352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 4480 KB Output is correct
2 Correct 11 ms 4480 KB Output is correct
3 Correct 11 ms 4480 KB Output is correct
4 Correct 12 ms 4352 KB Output is correct
5 Correct 11 ms 4352 KB Output is correct
6 Correct 11 ms 4480 KB Output is correct
7 Correct 11 ms 4480 KB Output is correct
8 Correct 12 ms 4352 KB Output is correct
9 Correct 12 ms 4352 KB Output is correct
10 Correct 12 ms 4480 KB Output is correct
11 Correct 12 ms 4352 KB Output is correct
12 Correct 12 ms 4480 KB Output is correct
13 Correct 12 ms 4352 KB Output is correct
14 Correct 11 ms 4352 KB Output is correct
15 Correct 12 ms 4352 KB Output is correct
16 Correct 12 ms 4352 KB Output is correct
17 Correct 11 ms 4480 KB Output is correct
18 Correct 11 ms 4352 KB Output is correct
19 Correct 12 ms 4480 KB Output is correct
20 Correct 11 ms 4352 KB Output is correct
21 Correct 12 ms 4480 KB Output is correct
22 Correct 11 ms 4352 KB Output is correct
23 Correct 12 ms 4352 KB Output is correct
24 Correct 14 ms 4352 KB Output is correct
25 Correct 12 ms 4352 KB Output is correct
26 Correct 12 ms 4352 KB Output is correct
27 Correct 12 ms 4352 KB Output is correct
28 Correct 12 ms 4352 KB Output is correct
29 Correct 11 ms 4480 KB Output is correct
30 Correct 11 ms 4352 KB Output is correct
31 Correct 12 ms 4352 KB Output is correct
32 Correct 16 ms 4480 KB Output is correct
33 Correct 11 ms 4352 KB Output is correct
34 Correct 12 ms 4352 KB Output is correct
35 Correct 12 ms 4352 KB Output is correct
36 Correct 11 ms 4352 KB Output is correct
37 Correct 11 ms 4352 KB Output is correct
38 Correct 12 ms 4352 KB Output is correct
39 Correct 13 ms 4352 KB Output is correct
40 Correct 12 ms 4352 KB Output is correct
41 Correct 11 ms 4352 KB Output is correct
42 Correct 12 ms 4452 KB Output is correct
43 Correct 11 ms 4352 KB Output is correct
44 Correct 12 ms 4480 KB Output is correct
45 Correct 12 ms 4480 KB Output is correct
46 Correct 11 ms 4352 KB Output is correct
47 Correct 12 ms 4480 KB Output is correct
48 Correct 14 ms 4352 KB Output is correct
49 Correct 12 ms 4352 KB Output is correct
50 Correct 12 ms 4352 KB Output is correct
51 Correct 12 ms 4352 KB Output is correct
52 Correct 11 ms 4352 KB Output is correct
53 Correct 12 ms 4480 KB Output is correct
54 Correct 12 ms 4352 KB Output is correct
55 Correct 14 ms 4480 KB Output is correct
56 Correct 11 ms 4352 KB Output is correct
57 Correct 12 ms 4352 KB Output is correct
58 Correct 12 ms 4480 KB Output is correct
59 Correct 11 ms 4352 KB Output is correct
60 Correct 12 ms 4352 KB Output is correct
61 Correct 11 ms 4480 KB Output is correct
62 Correct 12 ms 4352 KB Output is correct
63 Correct 13 ms 4352 KB Output is correct
64 Correct 12 ms 4352 KB Output is correct
65 Correct 11 ms 4352 KB Output is correct
66 Correct 12 ms 4352 KB Output is correct
67 Correct 12 ms 4480 KB Output is correct
68 Correct 12 ms 4352 KB Output is correct
69 Correct 12 ms 4480 KB Output is correct
70 Correct 12 ms 4352 KB Output is correct
71 Correct 12 ms 4352 KB Output is correct
72 Correct 12 ms 4352 KB Output is correct
73 Correct 12 ms 4352 KB Output is correct
74 Correct 12 ms 4352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 4480 KB Output is correct
2 Correct 11 ms 4400 KB Output is correct
3 Correct 11 ms 4352 KB Output is correct
4 Correct 11 ms 4352 KB Output is correct
5 Correct 11 ms 4352 KB Output is correct
6 Correct 11 ms 4480 KB Output is correct
7 Correct 11 ms 4352 KB Output is correct
8 Correct 13 ms 4352 KB Output is correct
9 Correct 12 ms 4352 KB Output is correct
10 Correct 12 ms 4352 KB Output is correct
11 Correct 16 ms 4352 KB Output is correct
12 Correct 12 ms 4480 KB Output is correct
13 Correct 11 ms 4352 KB Output is correct
14 Correct 11 ms 4352 KB Output is correct
15 Correct 11 ms 4352 KB Output is correct
16 Correct 11 ms 4352 KB Output is correct
17 Correct 12 ms 4352 KB Output is correct
18 Correct 11 ms 4352 KB Output is correct
19 Correct 12 ms 4480 KB Output is correct
20 Correct 11 ms 4352 KB Output is correct
21 Correct 12 ms 4480 KB Output is correct
22 Correct 12 ms 4352 KB Output is correct
23 Correct 11 ms 4352 KB Output is correct
24 Correct 12 ms 4352 KB Output is correct
25 Correct 11 ms 4352 KB Output is correct
26 Correct 12 ms 4480 KB Output is correct
27 Correct 12 ms 4352 KB Output is correct
28 Correct 12 ms 4352 KB Output is correct
29 Correct 14 ms 4352 KB Output is correct
30 Correct 12 ms 4352 KB Output is correct
31 Correct 12 ms 4352 KB Output is correct
32 Correct 16 ms 4480 KB Output is correct
33 Correct 12 ms 4352 KB Output is correct
34 Correct 12 ms 4352 KB Output is correct
35 Correct 11 ms 4352 KB Output is correct
36 Correct 11 ms 4352 KB Output is correct
37 Correct 12 ms 4352 KB Output is correct
38 Correct 12 ms 4480 KB Output is correct
39 Correct 12 ms 4352 KB Output is correct
40 Correct 12 ms 4352 KB Output is correct
41 Correct 11 ms 4352 KB Output is correct
42 Correct 12 ms 4352 KB Output is correct
43 Correct 12 ms 4352 KB Output is correct
44 Correct 12 ms 4352 KB Output is correct
45 Correct 12 ms 4352 KB Output is correct
46 Correct 11 ms 4352 KB Output is correct
47 Correct 11 ms 4480 KB Output is correct
48 Correct 13 ms 4352 KB Output is correct
49 Correct 12 ms 4352 KB Output is correct
50 Correct 13 ms 4352 KB Output is correct
51 Correct 12 ms 4352 KB Output is correct
52 Correct 143 ms 4352 KB Output is correct
53 Correct 18 ms 4608 KB Output is correct
54 Correct 279 ms 4352 KB Output is correct
55 Correct 258 ms 4352 KB Output is correct
56 Correct 823 ms 4480 KB Output is correct
57 Correct 43 ms 4480 KB Output is correct
58 Correct 60 ms 4480 KB Output is correct
59 Correct 82 ms 4480 KB Output is correct
60 Correct 25 ms 4352 KB Output is correct
61 Correct 13 ms 4352 KB Output is correct
62 Correct 16 ms 4480 KB Output is correct
63 Correct 307 ms 4472 KB Output is correct
64 Correct 18 ms 4480 KB Output is correct
65 Correct 478 ms 4480 KB Output is correct
66 Correct 35 ms 4480 KB Output is correct
67 Correct 22 ms 4476 KB Output is correct
68 Execution timed out 1098 ms 4352 KB Time limit exceeded
69 Halted 0 ms 0 KB -