Submission #339495

# Submission time Handle Problem Language Result Execution time Memory
339495 2020-12-25T13:55:51 Z blue Bali Sculptures (APIO15_sculpture) C++11
71 / 100
1000 ms 908 KB
#include <iostream>
#include <vector>
using namespace std;

//Subtask 1, 2, 3, 4: N <= 100
/*
For the worst beauty value, we want to first of all make the most significant bit as small as possible.

Loop through all the bits: log(max_N)    =  32
Loop through all the positions:     N    =  100
Loop through all the previous choices: N =  100
Loop through all the choices of x (a<x<b)=  100
Grand total                              = 32e6 = 3e7 √
*/

long long pow2[40];

//     arr size,   limits on x,   sculpture values
long long solve_1(long long N, long long A, long long B, vector<long long> Y)
{
    // for(long long y:Y) cout << y << ' ';
    // cout << '\n';


    long long dp[N+1][B+1]; //is it possible to partition 1..i long longo j groups such that no group has value v & 1<<bit == 1
    long long res = pow2[39] - 1, temp;   //fix this number
    long long curr_res = 0;
    for(long long bit = 38; bit >= 0; bit--) //fix this number
    {
        // cout << "bit = " << bit << '\n';
        for(long long i = 0; i <= N; i++) for(long long x = 0; x <= B; x++) dp[i][x] = 0;
        res -= pow2[bit];

        // cout << "res = " << res << '\n';

        dp[0][0] = 1;
        for(long long i = 1; i <= N; i++)
        {
            dp[i][1] = (Y[i] | res) <= res;
            for(long long x = 2; x <= B; x++)
            {
                for(long long j = 0; j < i; j++)
                {
                    if(((Y[i] - Y[j]) | res) > res) continue;
                    if(!dp[j][x-1]) continue;
                    // cout << i << ' ' << x << ' ' << j << ' ' << Y[i] - Y[j] << ' ' << res << '\n';
                    dp[i][x] |= dp[j][x-1];
                }
            }
        }

        // for(long long x = 1; x <= B; x++)
        // {
        //     for(long long i = 1; i <= N; i++)
        //     {
        //         cout << dp[i][x] << ' ';
        //     }
        //     cout << '\n';
        // }

        temp = 0;
        for(long long x = A; x <= B; x++) temp |= dp[N][x];
        if(!temp) res += pow2[bit];


        // cout << "______________________\n";
    }
    return res;
}

/*
-----------------------------------------------------
*/

//Subtask 3, 5: A = 1
/*

*/
long long solve_2(long long N, long long B, vector<long long> Y)
{
    return 0;
}

int main()
{
    pow2[0] = 1;
    for(int i = 1; i < 40; i++) pow2[i] = pow2[i-1] * 2;

    long long N, A, B;
    cin >> N >> A >> B;

    vector<long long> Y(N+1);
    Y[0] = 0;
    for(long long i = 1; i <= N; i++)
    {
        cin >> Y[i];
        Y[i] += Y[i-1];
    }

    /*if(N <= 100)*/cout << solve_1(N, A, B, Y) << '\n';
    //else cout << solve_2(N, B, Y) << '\n'; //A = 1
}

Compilation message

sculpture.cpp: In function 'long long int solve_1(long long int, long long int, long long int, std::vector<long long int>)':
sculpture.cpp:27:15: warning: unused variable 'curr_res' [-Wunused-variable]
   27 |     long long curr_res = 0;
      |               ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 372 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 4 ms 364 KB Output is correct
32 Correct 3 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 3 ms 364 KB Output is correct
22 Correct 3 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 3 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 7 ms 364 KB Output is correct
27 Correct 22 ms 364 KB Output is correct
28 Correct 46 ms 364 KB Output is correct
29 Correct 44 ms 364 KB Output is correct
30 Correct 0 ms 364 KB Output is correct
31 Correct 23 ms 492 KB Output is correct
32 Correct 33 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 2 ms 364 KB Output is correct
41 Correct 3 ms 364 KB Output is correct
42 Correct 3 ms 364 KB Output is correct
43 Correct 1 ms 364 KB Output is correct
44 Correct 3 ms 364 KB Output is correct
45 Correct 3 ms 364 KB Output is correct
46 Correct 2 ms 364 KB Output is correct
47 Correct 3 ms 364 KB Output is correct
48 Correct 2 ms 364 KB Output is correct
49 Correct 7 ms 364 KB Output is correct
50 Correct 21 ms 364 KB Output is correct
51 Correct 42 ms 364 KB Output is correct
52 Correct 43 ms 364 KB Output is correct
53 Correct 1 ms 364 KB Output is correct
54 Correct 22 ms 364 KB Output is correct
55 Correct 33 ms 364 KB Output is correct
56 Correct 3 ms 364 KB Output is correct
57 Correct 6 ms 364 KB Output is correct
58 Correct 17 ms 364 KB Output is correct
59 Correct 38 ms 364 KB Output is correct
60 Correct 36 ms 364 KB Output is correct
61 Correct 1 ms 364 KB Output is correct
62 Correct 38 ms 364 KB Output is correct
63 Correct 39 ms 364 KB Output is correct
64 Correct 32 ms 364 KB Output is correct
65 Correct 3 ms 364 KB Output is correct
66 Correct 2 ms 364 KB Output is correct
67 Correct 6 ms 364 KB Output is correct
68 Correct 17 ms 364 KB Output is correct
69 Correct 36 ms 364 KB Output is correct
70 Correct 36 ms 364 KB Output is correct
71 Correct 1 ms 364 KB Output is correct
72 Correct 38 ms 364 KB Output is correct
73 Correct 28 ms 364 KB Output is correct
74 Correct 25 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 0 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 4 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 3 ms 364 KB Output is correct
32 Correct 3 ms 364 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 2 ms 364 KB Output is correct
36 Correct 9 ms 364 KB Output is correct
37 Correct 21 ms 364 KB Output is correct
38 Correct 42 ms 364 KB Output is correct
39 Correct 42 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 22 ms 364 KB Output is correct
42 Correct 33 ms 364 KB Output is correct
43 Correct 3 ms 364 KB Output is correct
44 Correct 6 ms 364 KB Output is correct
45 Correct 17 ms 364 KB Output is correct
46 Correct 37 ms 384 KB Output is correct
47 Correct 37 ms 364 KB Output is correct
48 Correct 1 ms 364 KB Output is correct
49 Correct 38 ms 364 KB Output is correct
50 Correct 39 ms 372 KB Output is correct
51 Correct 10 ms 492 KB Output is correct
52 Execution timed out 1043 ms 908 KB Time limit exceeded
53 Halted 0 ms 0 KB -