Submission #75466

# Submission time Handle Problem Language Result Execution time Memory
75466 2018-09-09T20:50:39 Z MiricaMatei Bali Sculptures (APIO15_sculpture) C++14
100 / 100
118 ms 5596 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2005;

int v[MAX_N];
int dp1[MAX_N];
bool dp[MAX_N][MAX_N];

int n;
long long pref;

bool check1(int bit, int b) {
  dp1[0] = 0;
  for (int i = 1; i <= n; ++i) {
    dp1[i] = b + 1;
    long long s = 0;
    for (int j = i; j >= 1; --j) {
      s += v[j];
      if (dp1[j - 1] != b + 1 && (s & pref) == 0)
        dp1[i] = min(dp1[i], 1 + dp1[j - 1]);
    }
  }
  return dp1[n] <= b;
}

bool check2(int bit, int a, int b) {
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) {
      long long s = 0;
      for (int k = i; k >= j - 1; --k) {
        s += v[k];
        if (dp[k - 1][j - 1] == 1 && (s & pref) == 0) {
          dp[i][j] = 1;
          break;
        }
      }
    }
  }
  for (int i = a; i <= b; ++i)
    if (dp[n][i]) {
      return 1;
    }
  return 0;
}

bool sePoate(int bit, int a, int b) {
  pref |= (1LL << bit);
  if (a == 1)
    return check1(bit, b);
  else
    return check2(bit, a, b);
}

int main() {
  int a, b;
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &v[i]);
  for (int i = 41; i >= 0; --i) {
    if (!sePoate(i, a, b)) {
      pref ^= (1LL << i);
    }
  }


  printf("%lld", ((1LL << 42) - 1) ^ pref);

  return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:60:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &n, &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:62:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &v[i]);
     ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 636 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 788 KB Output is correct
8 Correct 2 ms 788 KB Output is correct
9 Correct 2 ms 788 KB Output is correct
10 Correct 2 ms 788 KB Output is correct
11 Correct 2 ms 788 KB Output is correct
12 Correct 2 ms 788 KB Output is correct
13 Correct 2 ms 788 KB Output is correct
14 Correct 13 ms 4548 KB Output is correct
15 Correct 13 ms 4684 KB Output is correct
16 Correct 14 ms 4684 KB Output is correct
17 Correct 13 ms 4684 KB Output is correct
18 Correct 13 ms 4684 KB Output is correct
19 Correct 13 ms 4684 KB Output is correct
20 Correct 15 ms 4684 KB Output is correct
21 Correct 14 ms 4684 KB Output is correct
22 Correct 16 ms 4684 KB Output is correct
23 Correct 14 ms 4684 KB Output is correct
24 Correct 13 ms 4684 KB Output is correct
25 Correct 13 ms 4684 KB Output is correct
26 Correct 15 ms 4684 KB Output is correct
27 Correct 2 ms 4684 KB Output is correct
28 Correct 2 ms 4684 KB Output is correct
29 Correct 2 ms 4684 KB Output is correct
30 Correct 3 ms 4684 KB Output is correct
31 Correct 2 ms 4684 KB Output is correct
32 Correct 3 ms 4684 KB Output is correct
33 Correct 2 ms 4684 KB Output is correct
34 Correct 3 ms 4684 KB Output is correct
35 Correct 3 ms 4684 KB Output is correct
36 Correct 2 ms 4684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4684 KB Output is correct
2 Correct 2 ms 4684 KB Output is correct
3 Correct 2 ms 4684 KB Output is correct
4 Correct 2 ms 4684 KB Output is correct
5 Correct 2 ms 4684 KB Output is correct
6 Correct 2 ms 4684 KB Output is correct
7 Correct 2 ms 4684 KB Output is correct
8 Correct 2 ms 4684 KB Output is correct
9 Correct 2 ms 4684 KB Output is correct
10 Correct 2 ms 4684 KB Output is correct
11 Correct 2 ms 4684 KB Output is correct
12 Correct 2 ms 4684 KB Output is correct
13 Correct 2 ms 4684 KB Output is correct
14 Correct 13 ms 4772 KB Output is correct
15 Correct 13 ms 4776 KB Output is correct
16 Correct 14 ms 4780 KB Output is correct
17 Correct 13 ms 4788 KB Output is correct
18 Correct 14 ms 4796 KB Output is correct
19 Correct 14 ms 4832 KB Output is correct
20 Correct 15 ms 4876 KB Output is correct
21 Correct 15 ms 4932 KB Output is correct
22 Correct 14 ms 4932 KB Output is correct
23 Correct 14 ms 4932 KB Output is correct
24 Correct 14 ms 4932 KB Output is correct
25 Correct 14 ms 4932 KB Output is correct
26 Correct 16 ms 4932 KB Output is correct
27 Correct 3 ms 4932 KB Output is correct
28 Correct 2 ms 4932 KB Output is correct
29 Correct 2 ms 4932 KB Output is correct
30 Correct 2 ms 4932 KB Output is correct
31 Correct 2 ms 4932 KB Output is correct
32 Correct 2 ms 4932 KB Output is correct
33 Correct 2 ms 4932 KB Output is correct
34 Correct 2 ms 4932 KB Output is correct
35 Correct 2 ms 4932 KB Output is correct
36 Correct 3 ms 4932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4932 KB Output is correct
2 Correct 2 ms 4932 KB Output is correct
3 Correct 3 ms 4932 KB Output is correct
4 Correct 2 ms 4932 KB Output is correct
5 Correct 2 ms 4932 KB Output is correct
6 Correct 3 ms 4932 KB Output is correct
7 Correct 2 ms 4932 KB Output is correct
8 Correct 2 ms 4932 KB Output is correct
9 Correct 2 ms 4932 KB Output is correct
10 Correct 2 ms 4932 KB Output is correct
11 Correct 2 ms 4932 KB Output is correct
12 Correct 2 ms 4932 KB Output is correct
13 Correct 3 ms 4932 KB Output is correct
14 Correct 2 ms 4932 KB Output is correct
15 Correct 2 ms 4932 KB Output is correct
16 Correct 2 ms 4932 KB Output is correct
17 Correct 2 ms 4932 KB Output is correct
18 Correct 2 ms 4932 KB Output is correct
19 Correct 2 ms 4932 KB Output is correct
20 Correct 2 ms 4932 KB Output is correct
21 Correct 2 ms 4932 KB Output is correct
22 Correct 3 ms 4932 KB Output is correct
23 Correct 2 ms 4932 KB Output is correct
24 Correct 2 ms 4932 KB Output is correct
25 Correct 2 ms 4932 KB Output is correct
26 Correct 2 ms 4932 KB Output is correct
27 Correct 3 ms 4932 KB Output is correct
28 Correct 3 ms 4932 KB Output is correct
29 Correct 3 ms 4932 KB Output is correct
30 Correct 3 ms 4932 KB Output is correct
31 Correct 3 ms 4932 KB Output is correct
32 Correct 3 ms 4932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4932 KB Output is correct
2 Correct 2 ms 4932 KB Output is correct
3 Correct 2 ms 4932 KB Output is correct
4 Correct 2 ms 4932 KB Output is correct
5 Correct 2 ms 4932 KB Output is correct
6 Correct 2 ms 4932 KB Output is correct
7 Correct 2 ms 4932 KB Output is correct
8 Correct 2 ms 4932 KB Output is correct
9 Correct 2 ms 4932 KB Output is correct
10 Correct 3 ms 4932 KB Output is correct
11 Correct 2 ms 4932 KB Output is correct
12 Correct 2 ms 4932 KB Output is correct
13 Correct 2 ms 4932 KB Output is correct
14 Correct 15 ms 5100 KB Output is correct
15 Correct 16 ms 5140 KB Output is correct
16 Correct 14 ms 5140 KB Output is correct
17 Correct 14 ms 5260 KB Output is correct
18 Correct 14 ms 5260 KB Output is correct
19 Correct 15 ms 5260 KB Output is correct
20 Correct 13 ms 5260 KB Output is correct
21 Correct 14 ms 5260 KB Output is correct
22 Correct 15 ms 5260 KB Output is correct
23 Correct 14 ms 5260 KB Output is correct
24 Correct 15 ms 5260 KB Output is correct
25 Correct 14 ms 5260 KB Output is correct
26 Correct 13 ms 5260 KB Output is correct
27 Correct 2 ms 5260 KB Output is correct
28 Correct 2 ms 5260 KB Output is correct
29 Correct 2 ms 5260 KB Output is correct
30 Correct 2 ms 5260 KB Output is correct
31 Correct 2 ms 5260 KB Output is correct
32 Correct 3 ms 5260 KB Output is correct
33 Correct 2 ms 5260 KB Output is correct
34 Correct 2 ms 5260 KB Output is correct
35 Correct 2 ms 5260 KB Output is correct
36 Correct 2 ms 5260 KB Output is correct
37 Correct 2 ms 5260 KB Output is correct
38 Correct 2 ms 5260 KB Output is correct
39 Correct 2 ms 5260 KB Output is correct
40 Correct 2 ms 5260 KB Output is correct
41 Correct 2 ms 5260 KB Output is correct
42 Correct 2 ms 5260 KB Output is correct
43 Correct 2 ms 5260 KB Output is correct
44 Correct 2 ms 5260 KB Output is correct
45 Correct 2 ms 5260 KB Output is correct
46 Correct 2 ms 5260 KB Output is correct
47 Correct 2 ms 5260 KB Output is correct
48 Correct 2 ms 5260 KB Output is correct
49 Correct 3 ms 5260 KB Output is correct
50 Correct 3 ms 5260 KB Output is correct
51 Correct 3 ms 5260 KB Output is correct
52 Correct 3 ms 5260 KB Output is correct
53 Correct 3 ms 5260 KB Output is correct
54 Correct 3 ms 5260 KB Output is correct
55 Correct 3 ms 5260 KB Output is correct
56 Correct 2 ms 5260 KB Output is correct
57 Correct 3 ms 5260 KB Output is correct
58 Correct 3 ms 5260 KB Output is correct
59 Correct 3 ms 5260 KB Output is correct
60 Correct 3 ms 5260 KB Output is correct
61 Correct 2 ms 5260 KB Output is correct
62 Correct 3 ms 5260 KB Output is correct
63 Correct 2 ms 5260 KB Output is correct
64 Correct 15 ms 5516 KB Output is correct
65 Correct 16 ms 5516 KB Output is correct
66 Correct 17 ms 5516 KB Output is correct
67 Correct 22 ms 5516 KB Output is correct
68 Correct 20 ms 5516 KB Output is correct
69 Correct 21 ms 5516 KB Output is correct
70 Correct 20 ms 5516 KB Output is correct
71 Correct 21 ms 5516 KB Output is correct
72 Correct 22 ms 5516 KB Output is correct
73 Correct 22 ms 5596 KB Output is correct
74 Correct 21 ms 5596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5596 KB Output is correct
2 Correct 2 ms 5596 KB Output is correct
3 Correct 2 ms 5596 KB Output is correct
4 Correct 2 ms 5596 KB Output is correct
5 Correct 2 ms 5596 KB Output is correct
6 Correct 2 ms 5596 KB Output is correct
7 Correct 2 ms 5596 KB Output is correct
8 Correct 2 ms 5596 KB Output is correct
9 Correct 2 ms 5596 KB Output is correct
10 Correct 2 ms 5596 KB Output is correct
11 Correct 2 ms 5596 KB Output is correct
12 Correct 2 ms 5596 KB Output is correct
13 Correct 2 ms 5596 KB Output is correct
14 Correct 2 ms 5596 KB Output is correct
15 Correct 2 ms 5596 KB Output is correct
16 Correct 2 ms 5596 KB Output is correct
17 Correct 2 ms 5596 KB Output is correct
18 Correct 2 ms 5596 KB Output is correct
19 Correct 2 ms 5596 KB Output is correct
20 Correct 2 ms 5596 KB Output is correct
21 Correct 2 ms 5596 KB Output is correct
22 Correct 2 ms 5596 KB Output is correct
23 Correct 2 ms 5596 KB Output is correct
24 Correct 2 ms 5596 KB Output is correct
25 Correct 2 ms 5596 KB Output is correct
26 Correct 2 ms 5596 KB Output is correct
27 Correct 2 ms 5596 KB Output is correct
28 Correct 2 ms 5596 KB Output is correct
29 Correct 2 ms 5596 KB Output is correct
30 Correct 2 ms 5596 KB Output is correct
31 Correct 2 ms 5596 KB Output is correct
32 Correct 2 ms 5596 KB Output is correct
33 Correct 2 ms 5596 KB Output is correct
34 Correct 2 ms 5596 KB Output is correct
35 Correct 2 ms 5596 KB Output is correct
36 Correct 2 ms 5596 KB Output is correct
37 Correct 2 ms 5596 KB Output is correct
38 Correct 3 ms 5596 KB Output is correct
39 Correct 3 ms 5596 KB Output is correct
40 Correct 3 ms 5596 KB Output is correct
41 Correct 3 ms 5596 KB Output is correct
42 Correct 3 ms 5596 KB Output is correct
43 Correct 2 ms 5596 KB Output is correct
44 Correct 3 ms 5596 KB Output is correct
45 Correct 3 ms 5596 KB Output is correct
46 Correct 2 ms 5596 KB Output is correct
47 Correct 4 ms 5596 KB Output is correct
48 Correct 3 ms 5596 KB Output is correct
49 Correct 3 ms 5596 KB Output is correct
50 Correct 2 ms 5596 KB Output is correct
51 Correct 3 ms 5596 KB Output is correct
52 Correct 15 ms 5596 KB Output is correct
53 Correct 17 ms 5596 KB Output is correct
54 Correct 35 ms 5596 KB Output is correct
55 Correct 41 ms 5596 KB Output is correct
56 Correct 109 ms 5596 KB Output is correct
57 Correct 96 ms 5596 KB Output is correct
58 Correct 94 ms 5596 KB Output is correct
59 Correct 91 ms 5596 KB Output is correct
60 Correct 118 ms 5596 KB Output is correct
61 Correct 3 ms 5596 KB Output is correct
62 Correct 17 ms 5596 KB Output is correct
63 Correct 56 ms 5596 KB Output is correct
64 Correct 27 ms 5596 KB Output is correct
65 Correct 50 ms 5596 KB Output is correct
66 Correct 75 ms 5596 KB Output is correct
67 Correct 100 ms 5596 KB Output is correct
68 Correct 110 ms 5596 KB Output is correct
69 Correct 94 ms 5596 KB Output is correct