Submission #435225

# Submission time Handle Problem Language Result Execution time Memory
435225 2021-06-23T05:44:23 Z iANikzad Bali Sculptures (APIO15_sculpture) C++14
100 / 100
330 ms 31964 KB
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define F first
#define S second
#define debug(x) cerr<<#x<<" :"<<x<<"\n"
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define FAST ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
#define int long long

typedef long long ll;
typedef long double ld;

const int maxn = 2e3 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int maxl = 43;
const int SQ = 400;

int n, x, y;
int ans = (1ll << maxl) - 1;

int a[maxn];
int dp[maxn], pd[maxn][maxn];

int check(int cur)
{
     memset(dp, 0, sizeof(dp)); memset(pd, 0, sizeof(pd));
     pd[0][0] = 1;

     for(int i = 1; i <= n; i++)
     {
        int sum = 0;
        dp[i] = +INF;

        for(int j = i - 1; j >= 0; j--)
        {
            sum += a[j + 1];
            if((sum | cur) != cur) continue;

            if(x == 1)
            {
                dp[i] = min(dp[i], dp[j] + 1);
                continue;
            }

            for(int k = 1; k <= i; k++)
                pd[i][k] |= pd[j][k - 1];
        }
     }

     if(x == 1) return (dp[n] <= y);
     for(int i = x; i <= y; i++) if(pd[n][i]) return 1;
     return 0;
}

int32_t main()
{
    FAST;

    cin >> n >> x >> y;

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    for(int i = maxl - 1; i >= 0; i--)
        if(check(ans ^ (1ll << i)))
            ans  ^= (1ll << i);

    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 199 ms 31820 KB Output is correct
2 Correct 193 ms 31948 KB Output is correct
3 Correct 186 ms 31820 KB Output is correct
4 Correct 195 ms 31820 KB Output is correct
5 Correct 189 ms 31856 KB Output is correct
6 Correct 195 ms 31860 KB Output is correct
7 Correct 191 ms 31836 KB Output is correct
8 Correct 198 ms 31844 KB Output is correct
9 Correct 196 ms 31820 KB Output is correct
10 Correct 203 ms 31852 KB Output is correct
11 Correct 190 ms 31820 KB Output is correct
12 Correct 179 ms 31820 KB Output is correct
13 Correct 187 ms 31820 KB Output is correct
14 Correct 183 ms 31820 KB Output is correct
15 Correct 206 ms 31844 KB Output is correct
16 Correct 206 ms 31840 KB Output is correct
17 Correct 191 ms 31820 KB Output is correct
18 Correct 202 ms 31820 KB Output is correct
19 Correct 187 ms 31820 KB Output is correct
20 Correct 189 ms 31876 KB Output is correct
21 Correct 192 ms 31836 KB Output is correct
22 Correct 187 ms 31728 KB Output is correct
23 Correct 193 ms 31844 KB Output is correct
24 Correct 200 ms 31840 KB Output is correct
25 Correct 188 ms 31940 KB Output is correct
26 Correct 204 ms 31844 KB Output is correct
27 Correct 198 ms 31836 KB Output is correct
28 Correct 198 ms 31764 KB Output is correct
29 Correct 188 ms 31836 KB Output is correct
30 Correct 189 ms 31844 KB Output is correct
31 Correct 183 ms 31940 KB Output is correct
32 Correct 202 ms 31840 KB Output is correct
33 Correct 190 ms 31820 KB Output is correct
34 Correct 190 ms 31836 KB Output is correct
35 Correct 183 ms 31820 KB Output is correct
36 Correct 196 ms 31844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 185 ms 31848 KB Output is correct
2 Correct 198 ms 31836 KB Output is correct
3 Correct 192 ms 31748 KB Output is correct
4 Correct 200 ms 31840 KB Output is correct
5 Correct 185 ms 31864 KB Output is correct
6 Correct 185 ms 31836 KB Output is correct
7 Correct 188 ms 31820 KB Output is correct
8 Correct 194 ms 31804 KB Output is correct
9 Correct 213 ms 31844 KB Output is correct
10 Correct 191 ms 31844 KB Output is correct
11 Correct 186 ms 31844 KB Output is correct
12 Correct 188 ms 31844 KB Output is correct
13 Correct 207 ms 31940 KB Output is correct
14 Correct 199 ms 31836 KB Output is correct
15 Correct 193 ms 31840 KB Output is correct
16 Correct 202 ms 31888 KB Output is correct
17 Correct 192 ms 31820 KB Output is correct
18 Correct 199 ms 31852 KB Output is correct
19 Correct 193 ms 31836 KB Output is correct
20 Correct 193 ms 31840 KB Output is correct
21 Correct 209 ms 31840 KB Output is correct
22 Correct 209 ms 31836 KB Output is correct
23 Correct 196 ms 31844 KB Output is correct
24 Correct 201 ms 31836 KB Output is correct
25 Correct 204 ms 31844 KB Output is correct
26 Correct 200 ms 31896 KB Output is correct
27 Correct 193 ms 31844 KB Output is correct
28 Correct 186 ms 31836 KB Output is correct
29 Correct 205 ms 31844 KB Output is correct
30 Correct 203 ms 31836 KB Output is correct
31 Correct 205 ms 31840 KB Output is correct
32 Correct 209 ms 31820 KB Output is correct
33 Correct 198 ms 31840 KB Output is correct
34 Correct 190 ms 31940 KB Output is correct
35 Correct 196 ms 31836 KB Output is correct
36 Correct 188 ms 31836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 207 ms 31820 KB Output is correct
2 Correct 191 ms 31852 KB Output is correct
3 Correct 179 ms 31832 KB Output is correct
4 Correct 187 ms 31820 KB Output is correct
5 Correct 178 ms 31820 KB Output is correct
6 Correct 187 ms 31900 KB Output is correct
7 Correct 182 ms 31820 KB Output is correct
8 Correct 181 ms 31848 KB Output is correct
9 Correct 197 ms 31840 KB Output is correct
10 Correct 206 ms 31836 KB Output is correct
11 Correct 194 ms 31840 KB Output is correct
12 Correct 183 ms 31820 KB Output is correct
13 Correct 200 ms 31848 KB Output is correct
14 Correct 205 ms 31840 KB Output is correct
15 Correct 183 ms 31836 KB Output is correct
16 Correct 192 ms 31940 KB Output is correct
17 Correct 195 ms 31840 KB Output is correct
18 Correct 188 ms 31840 KB Output is correct
19 Correct 189 ms 31820 KB Output is correct
20 Correct 210 ms 31820 KB Output is correct
21 Correct 190 ms 31820 KB Output is correct
22 Correct 183 ms 31844 KB Output is correct
23 Correct 202 ms 31820 KB Output is correct
24 Correct 178 ms 31844 KB Output is correct
25 Correct 187 ms 31832 KB Output is correct
26 Correct 190 ms 31940 KB Output is correct
27 Correct 188 ms 31820 KB Output is correct
28 Correct 197 ms 31840 KB Output is correct
29 Correct 211 ms 31836 KB Output is correct
30 Correct 186 ms 31836 KB Output is correct
31 Correct 191 ms 31940 KB Output is correct
32 Correct 198 ms 31860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 31840 KB Output is correct
2 Correct 201 ms 31840 KB Output is correct
3 Correct 191 ms 31912 KB Output is correct
4 Correct 190 ms 31840 KB Output is correct
5 Correct 194 ms 31848 KB Output is correct
6 Correct 183 ms 31820 KB Output is correct
7 Correct 199 ms 31840 KB Output is correct
8 Correct 199 ms 31832 KB Output is correct
9 Correct 194 ms 31964 KB Output is correct
10 Correct 183 ms 31820 KB Output is correct
11 Correct 195 ms 31940 KB Output is correct
12 Correct 196 ms 31836 KB Output is correct
13 Correct 186 ms 31840 KB Output is correct
14 Correct 204 ms 31848 KB Output is correct
15 Correct 196 ms 31820 KB Output is correct
16 Correct 196 ms 31840 KB Output is correct
17 Correct 187 ms 31820 KB Output is correct
18 Correct 195 ms 31820 KB Output is correct
19 Correct 201 ms 31940 KB Output is correct
20 Correct 197 ms 31844 KB Output is correct
21 Correct 198 ms 31820 KB Output is correct
22 Correct 194 ms 31772 KB Output is correct
23 Correct 197 ms 31840 KB Output is correct
24 Correct 202 ms 31848 KB Output is correct
25 Correct 179 ms 31840 KB Output is correct
26 Correct 184 ms 31840 KB Output is correct
27 Correct 181 ms 31844 KB Output is correct
28 Correct 186 ms 31844 KB Output is correct
29 Correct 194 ms 31820 KB Output is correct
30 Correct 188 ms 31836 KB Output is correct
31 Correct 186 ms 31836 KB Output is correct
32 Correct 188 ms 31840 KB Output is correct
33 Correct 182 ms 31836 KB Output is correct
34 Correct 187 ms 31840 KB Output is correct
35 Correct 187 ms 31836 KB Output is correct
36 Correct 197 ms 31748 KB Output is correct
37 Correct 195 ms 31840 KB Output is correct
38 Correct 197 ms 31840 KB Output is correct
39 Correct 196 ms 31872 KB Output is correct
40 Correct 184 ms 31832 KB Output is correct
41 Correct 185 ms 31820 KB Output is correct
42 Correct 197 ms 31940 KB Output is correct
43 Correct 201 ms 31820 KB Output is correct
44 Correct 186 ms 31840 KB Output is correct
45 Correct 198 ms 31820 KB Output is correct
46 Correct 208 ms 31820 KB Output is correct
47 Correct 187 ms 31844 KB Output is correct
48 Correct 197 ms 31816 KB Output is correct
49 Correct 183 ms 31940 KB Output is correct
50 Correct 191 ms 31768 KB Output is correct
51 Correct 193 ms 31836 KB Output is correct
52 Correct 200 ms 31820 KB Output is correct
53 Correct 183 ms 31844 KB Output is correct
54 Correct 200 ms 31836 KB Output is correct
55 Correct 181 ms 31840 KB Output is correct
56 Correct 203 ms 31828 KB Output is correct
57 Correct 190 ms 31844 KB Output is correct
58 Correct 182 ms 31820 KB Output is correct
59 Correct 204 ms 31820 KB Output is correct
60 Correct 199 ms 31820 KB Output is correct
61 Correct 183 ms 31760 KB Output is correct
62 Correct 199 ms 31840 KB Output is correct
63 Correct 201 ms 31836 KB Output is correct
64 Correct 201 ms 31820 KB Output is correct
65 Correct 194 ms 31940 KB Output is correct
66 Correct 190 ms 31820 KB Output is correct
67 Correct 189 ms 31840 KB Output is correct
68 Correct 208 ms 31740 KB Output is correct
69 Correct 197 ms 31820 KB Output is correct
70 Correct 193 ms 31836 KB Output is correct
71 Correct 207 ms 31840 KB Output is correct
72 Correct 209 ms 31844 KB Output is correct
73 Correct 193 ms 31840 KB Output is correct
74 Correct 202 ms 31776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 212 ms 31844 KB Output is correct
2 Correct 189 ms 31844 KB Output is correct
3 Correct 189 ms 31836 KB Output is correct
4 Correct 209 ms 31840 KB Output is correct
5 Correct 200 ms 31820 KB Output is correct
6 Correct 193 ms 31840 KB Output is correct
7 Correct 192 ms 31840 KB Output is correct
8 Correct 199 ms 31836 KB Output is correct
9 Correct 196 ms 31836 KB Output is correct
10 Correct 210 ms 31836 KB Output is correct
11 Correct 193 ms 31840 KB Output is correct
12 Correct 199 ms 31836 KB Output is correct
13 Correct 203 ms 31820 KB Output is correct
14 Correct 199 ms 31840 KB Output is correct
15 Correct 195 ms 31840 KB Output is correct
16 Correct 201 ms 31836 KB Output is correct
17 Correct 194 ms 31836 KB Output is correct
18 Correct 195 ms 31820 KB Output is correct
19 Correct 186 ms 31840 KB Output is correct
20 Correct 204 ms 31820 KB Output is correct
21 Correct 183 ms 31940 KB Output is correct
22 Correct 203 ms 31824 KB Output is correct
23 Correct 182 ms 31820 KB Output is correct
24 Correct 197 ms 31840 KB Output is correct
25 Correct 201 ms 31820 KB Output is correct
26 Correct 198 ms 31852 KB Output is correct
27 Correct 195 ms 31836 KB Output is correct
28 Correct 194 ms 31800 KB Output is correct
29 Correct 196 ms 31900 KB Output is correct
30 Correct 204 ms 31840 KB Output is correct
31 Correct 206 ms 31844 KB Output is correct
32 Correct 185 ms 31820 KB Output is correct
33 Correct 197 ms 31848 KB Output is correct
34 Correct 205 ms 31844 KB Output is correct
35 Correct 193 ms 31792 KB Output is correct
36 Correct 205 ms 31840 KB Output is correct
37 Correct 199 ms 31836 KB Output is correct
38 Correct 193 ms 31836 KB Output is correct
39 Correct 191 ms 31852 KB Output is correct
40 Correct 196 ms 31820 KB Output is correct
41 Correct 193 ms 31840 KB Output is correct
42 Correct 196 ms 31844 KB Output is correct
43 Correct 192 ms 31844 KB Output is correct
44 Correct 198 ms 31840 KB Output is correct
45 Correct 190 ms 31840 KB Output is correct
46 Correct 197 ms 31836 KB Output is correct
47 Correct 193 ms 31820 KB Output is correct
48 Correct 191 ms 31836 KB Output is correct
49 Correct 187 ms 31844 KB Output is correct
50 Correct 200 ms 31820 KB Output is correct
51 Correct 194 ms 31820 KB Output is correct
52 Correct 203 ms 31848 KB Output is correct
53 Correct 212 ms 31856 KB Output is correct
54 Correct 217 ms 31800 KB Output is correct
55 Correct 230 ms 31940 KB Output is correct
56 Correct 304 ms 31880 KB Output is correct
57 Correct 314 ms 31940 KB Output is correct
58 Correct 304 ms 31820 KB Output is correct
59 Correct 296 ms 31960 KB Output is correct
60 Correct 330 ms 31940 KB Output is correct
61 Correct 199 ms 31820 KB Output is correct
62 Correct 199 ms 31820 KB Output is correct
63 Correct 221 ms 31864 KB Output is correct
64 Correct 226 ms 31876 KB Output is correct
65 Correct 256 ms 31872 KB Output is correct
66 Correct 291 ms 31876 KB Output is correct
67 Correct 313 ms 31872 KB Output is correct
68 Correct 309 ms 31940 KB Output is correct
69 Correct 290 ms 31820 KB Output is correct