Submission #660849

# Submission time Handle Problem Language Result Execution time Memory
660849 2022-11-23T10:26:15 Z danikoynov Bali Sculptures (APIO15_sculpture) C++14
71 / 100
68 ms 468 KB
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll maxn = 101, maxbit = 62;

ll n, A, B, f[maxbit], aw[maxn];
ll dp[maxn][maxn][2];
ll a[maxn];
void solve()
{
    cin >> n >> A >> B;
    for (ll i = 1; i <= n; i ++)
        cin >> a[i];

        for (ll i = A; i <= B; i ++)
            aw[i] = 1;
            /// fix bit
    for (ll bit = maxbit - 1; bit >= 0; bit --)
    {
        dp[0][0][0] = dp[0][0][1] = 1;
        for (ll i = 1; i <= n; i ++)
            for (ll j = 1; j <= B; j ++)
            dp[i][j][0] = dp[i][j][1] = 0;

        for (ll i = 1; i <= n; i ++)
        {
            ll sum = 0;
            for (ll k = i; k > 0; k --)
            {
                sum += a[k];
                bool done = false;
                for (ll fbit = maxbit - 1; fbit > bit; fbit --)
                {
                    if ((sum & ((ll)(1) << fbit)) > 0 && f[fbit] == 0)
                    {
                        done = true;
                        break;
                    }
                }
                if (done)
                    continue;

                for (ll j = 1; j <= B; j ++)
                {
                    if (dp[k - 1][j - 1][1] == 1)
                        dp[i][j][1] = 1;
                }

                if ((sum & ((ll)(1) << bit)) > 0)
                    continue;

                for (ll j = 1; j <= B; j ++)
                {
                    if (dp[k - 1][j - 1][0] == 1)
                        dp[i][j][0] = 1;
                }

            }

        }            ll st = 1;
                for (ll j = A; j <= B; j ++)
                {
                    if (aw[j] && dp[n][j][0] == 1)
                        st = 0;
                }

            if (st == 1)
            {
                f[bit] = 1;
                for (ll j = A; j <= B; j ++)
                    aw[j] = min(aw[j], dp[n][j][1]);
            }
            else
            {
                for (ll j = A; j <= B; j ++)
                    aw[j] = min(aw[j], dp[n][j][0]);
            }
            //exit(0);
    }

    ll ans = 0;
    for (ll bit = 0; bit < maxbit; bit ++)
        if (f[bit])
        ans = ans + ((ll)(1) << bit);

    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}
/**
6 1 3
8 1 2 1 5 4
*/

Compilation message

sculpture.cpp: In function 'void solve()':
sculpture.cpp:22:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   22 |     for (ll i = 1; i <= n; i ++)
      |     ^~~
sculpture.cpp:25:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   25 |         for (ll i = A; i <= B; i ++)
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 244 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 308 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 1 ms 304 KB Output is correct
36 Correct 2 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 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 252 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 4 ms 340 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Correct 7 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 7 ms 380 KB Output is correct
35 Correct 6 ms 384 KB Output is correct
36 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 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 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 5 ms 340 KB Output is correct
18 Correct 7 ms 340 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 7 ms 340 KB Output is correct
22 Correct 5 ms 380 KB Output is correct
23 Correct 4 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 7 ms 408 KB Output is correct
26 Correct 15 ms 340 KB Output is correct
27 Correct 39 ms 440 KB Output is correct
28 Correct 67 ms 340 KB Output is correct
29 Correct 66 ms 440 KB Output is correct
30 Correct 11 ms 340 KB Output is correct
31 Correct 40 ms 340 KB Output is correct
32 Correct 54 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 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 2 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 2 ms 340 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 4 ms 340 KB Output is correct
41 Correct 6 ms 340 KB Output is correct
42 Correct 6 ms 340 KB Output is correct
43 Correct 3 ms 340 KB Output is correct
44 Correct 7 ms 340 KB Output is correct
45 Correct 6 ms 340 KB Output is correct
46 Correct 6 ms 304 KB Output is correct
47 Correct 8 ms 388 KB Output is correct
48 Correct 7 ms 308 KB Output is correct
49 Correct 16 ms 340 KB Output is correct
50 Correct 37 ms 436 KB Output is correct
51 Correct 68 ms 440 KB Output is correct
52 Correct 66 ms 340 KB Output is correct
53 Correct 11 ms 436 KB Output is correct
54 Correct 40 ms 340 KB Output is correct
55 Correct 54 ms 460 KB Output is correct
56 Correct 5 ms 340 KB Output is correct
57 Correct 11 ms 340 KB Output is correct
58 Correct 23 ms 340 KB Output is correct
59 Correct 40 ms 456 KB Output is correct
60 Correct 38 ms 448 KB Output is correct
61 Correct 10 ms 340 KB Output is correct
62 Correct 44 ms 340 KB Output is correct
63 Correct 44 ms 340 KB Output is correct
64 Correct 56 ms 340 KB Output is correct
65 Correct 5 ms 340 KB Output is correct
66 Correct 5 ms 340 KB Output is correct
67 Correct 11 ms 340 KB Output is correct
68 Correct 23 ms 340 KB Output is correct
69 Correct 39 ms 340 KB Output is correct
70 Correct 37 ms 444 KB Output is correct
71 Correct 10 ms 468 KB Output is correct
72 Correct 45 ms 340 KB Output is correct
73 Correct 36 ms 340 KB Output is correct
74 Correct 34 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 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 316 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 5 ms 340 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 6 ms 388 KB Output is correct
32 Correct 6 ms 388 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 7 ms 340 KB Output is correct
35 Correct 7 ms 304 KB Output is correct
36 Correct 15 ms 432 KB Output is correct
37 Correct 37 ms 340 KB Output is correct
38 Correct 66 ms 440 KB Output is correct
39 Correct 67 ms 452 KB Output is correct
40 Correct 11 ms 340 KB Output is correct
41 Correct 39 ms 340 KB Output is correct
42 Correct 54 ms 340 KB Output is correct
43 Correct 5 ms 312 KB Output is correct
44 Correct 11 ms 340 KB Output is correct
45 Correct 23 ms 340 KB Output is correct
46 Correct 40 ms 340 KB Output is correct
47 Correct 38 ms 340 KB Output is correct
48 Correct 10 ms 468 KB Output is correct
49 Correct 45 ms 444 KB Output is correct
50 Correct 44 ms 340 KB Output is correct
51 Incorrect 17 ms 340 KB Output isn't correct
52 Halted 0 ms 0 KB -