답안 #740633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
740633 2023-05-12T22:44:08 Z abczz Bali Sculptures (APIO15_sculpture) C++14
100 / 100
87 ms 8408 KB
#include <iostream>
#define ll long long

using namespace std;

ll n, a, b, f, z, mn, x, y, A[2000], ps[2000], MX[2000][2000], dp[2000][2000];

void AOne() {
  for (int t=40; t>=0; --t) {
    z = (1LL << t);
    for (int i=0; i<n; ++i) {
      dp[i][0] = 1e18;
      if ((ps[i] & x) == 0 && (ps[i] & z) == 0) dp[i][0] = 1;
      for (int k=0; k<i; ++k) {
        y = ps[i]-ps[k];
        if ((y & x) == 0 && (y & z) == 0) {
          dp[i][0] = min(dp[i][0], dp[k][0]+1);
        }
      }
    }
    if (dp[n-1][0] <= b) x += z;
    else f += z;
  }
  cout << f << '\n';
}

void ANot() {
  for (int t=40; t>=0; --t) {
    z = (1LL << t);
    for (int i=0; i<n; ++i) {
      for (int j=0; j<n; ++j) {
        dp[i][j] = 1e18;
        if (!j && (ps[i] & x) == 0) dp[i][j] = ps[i] & z;
        if (!j) continue;
        for (int k=0; k<i; ++k) {
          y = ps[i]-ps[k];
          if (dp[k][j-1] != 1e18 && (y & x) == 0) {
            dp[i][j] = min(dp[i][j], dp[k][j-1] | (y & z));
          }
        }
      }
    }
    mn = 1e18;
    for (int i=a-1; i<b; ++i) {
      mn = min(mn, dp[n-1][i]);
    }
    if (!mn) x += z;
    else f += z;
  }
  cout << f << '\n';
}

int main() {
  cin >> n >> a >> b;
  for (int i=0; i<n; ++i) {
    cin >> A[i];
    if (!i) ps[i] = A[i];
    else ps[i] = ps[i-1]+A[i];
  }
  if (a == 1) AOne();
  else ANot();
}
# 결과 실행 시간 메모리 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 304 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 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 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 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 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 308 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 1 ms 308 KB Output is correct
29 Correct 0 ms 308 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 308 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 300 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 340 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 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 304 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 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 304 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 400 KB Output is correct
26 Correct 1 ms 312 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 436 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 436 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 440 KB Output is correct
36 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 308 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 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 312 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 436 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 436 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 432 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 560 KB Output is correct
26 Correct 1 ms 560 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 688 KB Output is correct
29 Correct 1 ms 596 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 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 1 ms 340 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 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 0 ms 312 KB Output is correct
13 Correct 0 ms 308 KB Output is correct
14 Correct 0 ms 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 312 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 304 KB Output is correct
24 Correct 2 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 0 ms 212 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 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 1 ms 308 KB Output is correct
36 Correct 1 ms 312 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 436 KB Output is correct
40 Correct 1 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 468 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 468 KB Output is correct
46 Correct 1 ms 436 KB Output is correct
47 Correct 1 ms 468 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 1 ms 568 KB Output is correct
50 Correct 1 ms 572 KB Output is correct
51 Correct 1 ms 736 KB Output is correct
52 Correct 1 ms 736 KB Output is correct
53 Correct 1 ms 708 KB Output is correct
54 Correct 2 ms 608 KB Output is correct
55 Correct 1 ms 704 KB Output is correct
56 Correct 1 ms 480 KB Output is correct
57 Correct 1 ms 608 KB Output is correct
58 Correct 1 ms 608 KB Output is correct
59 Correct 1 ms 608 KB Output is correct
60 Correct 1 ms 700 KB Output is correct
61 Correct 1 ms 608 KB Output is correct
62 Correct 1 ms 608 KB Output is correct
63 Correct 1 ms 736 KB Output is correct
64 Correct 30 ms 736 KB Output is correct
65 Correct 5 ms 480 KB Output is correct
66 Correct 10 ms 596 KB Output is correct
67 Correct 18 ms 596 KB Output is correct
68 Correct 27 ms 724 KB Output is correct
69 Correct 35 ms 724 KB Output is correct
70 Correct 34 ms 724 KB Output is correct
71 Correct 32 ms 724 KB Output is correct
72 Correct 35 ms 724 KB Output is correct
73 Correct 36 ms 724 KB Output is correct
74 Correct 36 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 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 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 1 ms 340 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 308 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 0 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 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 432 KB Output is correct
32 Correct 1 ms 436 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 596 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 1 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 1 ms 724 KB Output is correct
41 Correct 1 ms 596 KB Output is correct
42 Correct 1 ms 596 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 1 ms 596 KB Output is correct
45 Correct 1 ms 676 KB Output is correct
46 Correct 1 ms 688 KB Output is correct
47 Correct 1 ms 700 KB Output is correct
48 Correct 1 ms 700 KB Output is correct
49 Correct 1 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 1 ms 732 KB Output is correct
52 Correct 9 ms 2624 KB Output is correct
53 Correct 13 ms 3292 KB Output is correct
54 Correct 24 ms 4352 KB Output is correct
55 Correct 23 ms 4364 KB Output is correct
56 Correct 87 ms 8400 KB Output is correct
57 Correct 84 ms 8404 KB Output is correct
58 Correct 77 ms 8332 KB Output is correct
59 Correct 77 ms 8408 KB Output is correct
60 Correct 87 ms 8404 KB Output is correct
61 Correct 1 ms 688 KB Output is correct
62 Correct 14 ms 3340 KB Output is correct
63 Correct 26 ms 4308 KB Output is correct
64 Correct 23 ms 4308 KB Output is correct
65 Correct 40 ms 5972 KB Output is correct
66 Correct 63 ms 7380 KB Output is correct
67 Correct 79 ms 8404 KB Output is correct
68 Correct 81 ms 8408 KB Output is correct
69 Correct 78 ms 8404 KB Output is correct