Submission #108945

# Submission time Handle Problem Language Result Execution time Memory
108945 2019-05-03T04:37:12 Z mirbek01 Bali Sculptures (APIO15_sculpture) C++11
100 / 100
228 ms 16292 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 2e3 + 2;

int n, a[N], dp[N][N], d[N], used[N], l, r;
long long pref[N], ans;
vector <int> g[N];

bool check(){
      if(l > 1){
            memset(dp, 0, sizeof(dp));
            dp[0][0] = 1;
            for(int i = 1; i <= r; i ++){
                  for(int j = 1; j <= n; j ++){
                        for(int k = 0; k < j; k ++){
                              if(((pref[j] - pref[k]) | ans) == ans){
                                    dp[i][j] |= dp[i - 1][k];
                              }
                        }
                  }
            }
            int ret = 0;
            for(int i = l; i <= r; i ++){
                  ret |= dp[i][n];
            }
            return ret;
      } else {
            memset(d, 0x3f3f3f3f, sizeof(d));
            memset(used, 0, sizeof(used));
            for(int i = 0; i < n; i ++){
                  g[i].clear();
                  for(int j = i + 1; j <= n; j ++){
                        if(((pref[j] - pref[i]) | ans) == ans)
                              g[i].push_back(j);
                  }
            }
            d[0] = 0;
            used[0] = 1;
            queue <int> q;
            q.push(0);
            while(!q.empty()){
                  int v = q.front();
                  q.pop();
                  for(int to : g[v]){
                        if(!used[to]){
                              d[to] = d[v] + 1;
                              used[to] = 1;
                              q.push(to);
                        }
                  }
            }
            return d[n] <= r;
      }
}

int main(){
      cin >> n >> l >> r;

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

      ans = (1LL << 41) - 1;

      for(int i = 40; i >= 0; i --){
            ans -= (1LL << i);
            if(!check())
                  ans += (1LL << i);
      }

      cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 137 ms 16128 KB Output is correct
15 Correct 152 ms 16100 KB Output is correct
16 Correct 106 ms 16128 KB Output is correct
17 Correct 55 ms 16128 KB Output is correct
18 Correct 140 ms 16000 KB Output is correct
19 Correct 179 ms 16220 KB Output is correct
20 Correct 159 ms 16096 KB Output is correct
21 Correct 130 ms 16128 KB Output is correct
22 Correct 152 ms 16104 KB Output is correct
23 Correct 139 ms 16220 KB Output is correct
24 Correct 206 ms 16248 KB Output is correct
25 Correct 134 ms 16128 KB Output is correct
26 Correct 138 ms 16128 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 92 ms 16128 KB Output is correct
15 Correct 117 ms 16248 KB Output is correct
16 Correct 137 ms 16096 KB Output is correct
17 Correct 126 ms 16104 KB Output is correct
18 Correct 134 ms 16128 KB Output is correct
19 Correct 128 ms 16128 KB Output is correct
20 Correct 152 ms 16152 KB Output is correct
21 Correct 146 ms 16140 KB Output is correct
22 Correct 138 ms 16128 KB Output is correct
23 Correct 132 ms 16128 KB Output is correct
24 Correct 144 ms 16248 KB Output is correct
25 Correct 139 ms 16132 KB Output is correct
26 Correct 94 ms 16096 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 428 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 428 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 512 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 2 ms 428 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 55 ms 16128 KB Output is correct
15 Correct 136 ms 16120 KB Output is correct
16 Correct 127 ms 16128 KB Output is correct
17 Correct 136 ms 16128 KB Output is correct
18 Correct 67 ms 16292 KB Output is correct
19 Correct 72 ms 16128 KB Output is correct
20 Correct 132 ms 16128 KB Output is correct
21 Correct 132 ms 16000 KB Output is correct
22 Correct 117 ms 16128 KB Output is correct
23 Correct 105 ms 16128 KB Output is correct
24 Correct 116 ms 16096 KB Output is correct
25 Correct 131 ms 16128 KB Output is correct
26 Correct 139 ms 16012 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 2 ms 404 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 3 ms 384 KB Output is correct
44 Correct 3 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 4 ms 512 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
54 Correct 3 ms 384 KB Output is correct
55 Correct 3 ms 384 KB Output is correct
56 Correct 3 ms 384 KB Output is correct
57 Correct 3 ms 384 KB Output is correct
58 Correct 3 ms 384 KB Output is correct
59 Correct 4 ms 512 KB Output is correct
60 Correct 3 ms 384 KB Output is correct
61 Correct 4 ms 512 KB Output is correct
62 Correct 3 ms 384 KB Output is correct
63 Correct 3 ms 512 KB Output is correct
64 Correct 157 ms 16220 KB Output is correct
65 Correct 143 ms 16128 KB Output is correct
66 Correct 76 ms 16248 KB Output is correct
67 Correct 134 ms 16128 KB Output is correct
68 Correct 156 ms 16128 KB Output is correct
69 Correct 195 ms 16000 KB Output is correct
70 Correct 100 ms 15976 KB Output is correct
71 Correct 127 ms 16120 KB Output is correct
72 Correct 174 ms 15992 KB Output is correct
73 Correct 157 ms 16132 KB Output is correct
74 Correct 149 ms 16120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 316 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 4 ms 428 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 3 ms 432 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 4 ms 384 KB Output is correct
38 Correct 3 ms 428 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 4 ms 512 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 3 ms 384 KB Output is correct
44 Correct 3 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 3 ms 384 KB Output is correct
48 Correct 3 ms 376 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 3 ms 512 KB Output is correct
51 Correct 2 ms 512 KB Output is correct
52 Correct 21 ms 1536 KB Output is correct
53 Correct 31 ms 1968 KB Output is correct
54 Correct 57 ms 3192 KB Output is correct
55 Correct 54 ms 3072 KB Output is correct
56 Correct 205 ms 11088 KB Output is correct
57 Correct 204 ms 11008 KB Output is correct
58 Correct 211 ms 11044 KB Output is correct
59 Correct 219 ms 11128 KB Output is correct
60 Correct 228 ms 11008 KB Output is correct
61 Correct 2 ms 384 KB Output is correct
62 Correct 31 ms 2048 KB Output is correct
63 Correct 56 ms 3072 KB Output is correct
64 Correct 53 ms 3072 KB Output is correct
65 Correct 107 ms 6272 KB Output is correct
66 Correct 162 ms 8960 KB Output is correct
67 Correct 213 ms 11008 KB Output is correct
68 Correct 228 ms 11052 KB Output is correct
69 Correct 204 ms 11008 KB Output is correct