답안 #609596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
609596 2022-07-27T17:48:12 Z Plurm Bali Sculptures (APIO15_sculpture) C++11
100 / 100
508 ms 4332 KB
#include <bits/stdc++.h>
using namespace std;

int y[2048];
int dp[2048];
bool check[2048][2048];
bool dps[128][128];
long long qs[2048];
int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d", y + i);
    qs[i] = qs[i - 1] + y[i];
  }
  long long oldmask = 0ll;
  for (long long bit = 60; bit >= 0; bit--) {
    long long mask = oldmask | ((1ll << bit) - 1ll);
    for (int i = 1; i <= n; i++) {
      long long sum = 0ll;
      for (int j = i; j <= n; j++) {
        sum += y[j];
        check[i][j] = (sum | mask) == mask;
      }
    }
    if (a == 1) {
      for (int i = 1; i <= n; i++) {
        if (check[1][i])
          dp[i] = 1;
        else
          dp[i] = 1e9;
        for (int j = 1; j < i; j++) {
          if (check[j + 1][i]) {
            dp[i] = min(dp[j] + 1, dp[i]);
          }
        }
      }
      if (dp[n] > b) {
        oldmask |= 1ll << bit;
      }
    } else {
      dps[0][0] = true;
      for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
          dps[k][i] = false;
          for (int j = 0; j < i; j++) {
            if (check[j + 1][i] && dps[k - 1][j]) {
              dps[k][i] = true;
            }
          }
        }
      }
      bool ok = false;
      for (int k = a; k <= b; k++)
        ok |= dps[k][n];
      if (!ok) {
        oldmask |= 1ll << bit;
      }
    }
  }
  printf("%lld\n", oldmask);
  return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d%d%d", &n, &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", y + i);
      |     ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 340 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 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 312 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 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 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 308 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 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 1 ms 340 KB Output is correct
35 Correct 1 ms 308 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 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 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 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 340 KB Output is correct
21 Correct 1 ms 340 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 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 2 ms 516 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 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 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 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 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 312 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 312 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 468 KB Output is correct
50 Correct 1 ms 468 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 2 ms 468 KB Output is correct
55 Correct 2 ms 468 KB Output is correct
56 Correct 1 ms 308 KB Output is correct
57 Correct 1 ms 468 KB Output is correct
58 Correct 1 ms 468 KB Output is correct
59 Correct 2 ms 468 KB Output is correct
60 Correct 2 ms 468 KB Output is correct
61 Correct 2 ms 468 KB Output is correct
62 Correct 2 ms 468 KB Output is correct
63 Correct 2 ms 468 KB Output is correct
64 Correct 32 ms 468 KB Output is correct
65 Correct 7 ms 340 KB Output is correct
66 Correct 13 ms 460 KB Output is correct
67 Correct 20 ms 468 KB Output is correct
68 Correct 36 ms 432 KB Output is correct
69 Correct 41 ms 528 KB Output is correct
70 Correct 38 ms 512 KB Output is correct
71 Correct 45 ms 516 KB Output is correct
72 Correct 57 ms 468 KB Output is correct
73 Correct 44 ms 468 KB Output is correct
74 Correct 41 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 0 ms 340 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 0 ms 352 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 292 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 224 KB Output is correct
15 Correct 1 ms 216 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 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 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 1 ms 468 KB Output is correct
39 Correct 2 ms 468 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 2 ms 468 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 2 ms 468 KB Output is correct
50 Correct 1 ms 468 KB Output is correct
51 Correct 1 ms 468 KB Output is correct
52 Correct 35 ms 1364 KB Output is correct
53 Correct 57 ms 1804 KB Output is correct
54 Correct 108 ms 2380 KB Output is correct
55 Correct 109 ms 2260 KB Output is correct
56 Correct 414 ms 4328 KB Output is correct
57 Correct 508 ms 4324 KB Output is correct
58 Correct 429 ms 4324 KB Output is correct
59 Correct 417 ms 4332 KB Output is correct
60 Correct 454 ms 4324 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 59 ms 1748 KB Output is correct
63 Correct 106 ms 2316 KB Output is correct
64 Correct 105 ms 2320 KB Output is correct
65 Correct 210 ms 3124 KB Output is correct
66 Correct 324 ms 3816 KB Output is correct
67 Correct 433 ms 4324 KB Output is correct
68 Correct 432 ms 4324 KB Output is correct
69 Correct 431 ms 4324 KB Output is correct