답안 #339491

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339491 2020-12-25T13:51:26 Z blue Bali Sculptures (APIO15_sculpture) C++11
46 / 100
37 ms 508 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 √
*/

//     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 = (1LL << 35) - 1, temp;   //fix this number
    long long curr_res = 0;
    for(long long bit = 34; 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 -= (1LL << 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 += (1LL << 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()
{
    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:25:15: warning: unused variable 'curr_res' [-Wunused-variable]
   25 |     long long curr_res = 0;
      |               ^~~~~~~~
# 결과 실행 시간 메모리 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 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 0 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 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
# 결과 실행 시간 메모리 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 256 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 0 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 0 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 3 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 2 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 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 2 ms 384 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 364 KB Output is correct
21 Correct 3 ms 364 KB Output is correct
22 Correct 2 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 6 ms 364 KB Output is correct
27 Correct 18 ms 364 KB Output is correct
28 Correct 36 ms 508 KB Output is correct
29 Correct 35 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 19 ms 364 KB Output is correct
32 Correct 29 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 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 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 2 ms 364 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 3 ms 364 KB Output is correct
48 Correct 2 ms 364 KB Output is correct
49 Correct 6 ms 364 KB Output is correct
50 Correct 18 ms 364 KB Output is correct
51 Correct 35 ms 364 KB Output is correct
52 Correct 37 ms 364 KB Output is correct
53 Correct 1 ms 364 KB Output is correct
54 Correct 19 ms 364 KB Output is correct
55 Correct 27 ms 364 KB Output is correct
56 Correct 3 ms 364 KB Output is correct
57 Correct 5 ms 364 KB Output is correct
58 Correct 15 ms 364 KB Output is correct
59 Correct 31 ms 364 KB Output is correct
60 Correct 32 ms 364 KB Output is correct
61 Incorrect 1 ms 364 KB Output isn't correct
62 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 0 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 2 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 3 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 2 ms 364 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 2 ms 364 KB Output is correct
36 Correct 6 ms 364 KB Output is correct
37 Correct 18 ms 364 KB Output is correct
38 Correct 36 ms 364 KB Output is correct
39 Correct 35 ms 448 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 21 ms 364 KB Output is correct
42 Correct 27 ms 364 KB Output is correct
43 Correct 3 ms 364 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 15 ms 384 KB Output is correct
46 Correct 31 ms 364 KB Output is correct
47 Correct 31 ms 384 KB Output is correct
48 Incorrect 1 ms 364 KB Output isn't correct
49 Halted 0 ms 0 KB -