답안 #109830

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109830 2019-05-08T06:49:54 Z PeppaPig Bali Sculptures (APIO15_sculpture) C++14
21 / 100
1000 ms 4332 KB
#include <bits/stdc++.h>

#define long long long

using namespace std;

const int N = 2e3+5;

int n, A, B;
long pref[N];
bool C[N][N];

bool chk(long mid) {
    if(A == 1) {
        long ans = 0;
        for(int bit = 62; ~bit; bit--) {
            int dp[N]; fill_n(dp, N, 1e9);
            dp[0] = 0;
            for(int i = 1; i <= n; i++) for(int j = i; j <= n; j++) {
                long sum = pref[j] - pref[i-1];
                if(!(sum >> bit & 1) && ((sum | ans) >> (bit + 1)) == (ans >> (bit + 1)))
                    dp[j] = min(dp[j], dp[i-1] + 1);
            }
            if(dp[n] > B) ans |= (1ll << bit);
        }
        return (ans <= mid);
    } else {
        memset(C, 0, sizeof C);
        C[0][0] = true;
        for(int k = 1; k <= n; k++) for(int i = 1; i <= n; i++) for(int j = i; j <= n; j++) {
            long sum = pref[j] - pref[i-1];
            if((sum & mid) == sum) C[j][k] |= C[i-1][k-1]; 
        }
        for(int i = 1; i <= n; i++) for(int j = A; j <= B; j++) if(C[i][j]) return true;
        return false;
    }
}

int main() {
    scanf("%d %d %d", &n, &A, &B);
    for(int i = 1; i <= n; i++) scanf("%lld", pref+i), pref[i] += pref[i-1];

    long l = 0, r = 1e18;
    while(l < r) {
        long mid = (l + r) >> 1;
        if(chk(mid)) r = mid;
        else l = mid + 1;
    }
    printf("%lld\n", r);

    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:40:10: 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:41:54: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%lld", pref+i), pref[i] += pref[i-1];
                                 ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 7 ms 256 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Incorrect 15 ms 4224 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 11 ms 384 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 8 ms 256 KB Output is correct
14 Incorrect 16 ms 4224 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 8 ms 408 KB Output is correct
11 Correct 8 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 256 KB Output is correct
15 Correct 8 ms 384 KB Output is correct
16 Correct 11 ms 256 KB Output is correct
17 Correct 13 ms 384 KB Output is correct
18 Correct 15 ms 256 KB Output is correct
19 Correct 15 ms 512 KB Output is correct
20 Correct 15 ms 412 KB Output is correct
21 Correct 17 ms 384 KB Output is correct
22 Correct 19 ms 256 KB Output is correct
23 Correct 18 ms 384 KB Output is correct
24 Correct 24 ms 256 KB Output is correct
25 Correct 29 ms 256 KB Output is correct
26 Correct 33 ms 256 KB Output is correct
27 Correct 44 ms 384 KB Output is correct
28 Correct 47 ms 384 KB Output is correct
29 Correct 43 ms 256 KB Output is correct
30 Correct 45 ms 384 KB Output is correct
31 Correct 67 ms 404 KB Output is correct
32 Correct 74 ms 356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 256 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 8 ms 384 KB Output is correct
8 Correct 10 ms 384 KB Output is correct
9 Correct 8 ms 256 KB Output is correct
10 Correct 10 ms 384 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 9 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Incorrect 18 ms 4332 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 7 ms 356 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 7 ms 256 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 10 ms 256 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 8 ms 256 KB Output is correct
18 Correct 8 ms 384 KB Output is correct
19 Correct 8 ms 384 KB Output is correct
20 Correct 10 ms 256 KB Output is correct
21 Correct 8 ms 256 KB Output is correct
22 Correct 7 ms 256 KB Output is correct
23 Correct 8 ms 384 KB Output is correct
24 Correct 7 ms 256 KB Output is correct
25 Correct 8 ms 432 KB Output is correct
26 Correct 11 ms 256 KB Output is correct
27 Correct 14 ms 384 KB Output is correct
28 Correct 15 ms 384 KB Output is correct
29 Correct 17 ms 256 KB Output is correct
30 Correct 21 ms 376 KB Output is correct
31 Correct 16 ms 256 KB Output is correct
32 Correct 17 ms 356 KB Output is correct
33 Correct 17 ms 384 KB Output is correct
34 Correct 19 ms 256 KB Output is correct
35 Correct 24 ms 384 KB Output is correct
36 Correct 30 ms 344 KB Output is correct
37 Correct 40 ms 384 KB Output is correct
38 Correct 45 ms 376 KB Output is correct
39 Correct 46 ms 376 KB Output is correct
40 Correct 40 ms 384 KB Output is correct
41 Correct 58 ms 256 KB Output is correct
42 Correct 46 ms 256 KB Output is correct
43 Correct 23 ms 256 KB Output is correct
44 Correct 47 ms 384 KB Output is correct
45 Correct 66 ms 504 KB Output is correct
46 Correct 75 ms 376 KB Output is correct
47 Correct 42 ms 384 KB Output is correct
48 Correct 42 ms 256 KB Output is correct
49 Correct 67 ms 364 KB Output is correct
50 Correct 73 ms 256 KB Output is correct
51 Correct 88 ms 364 KB Output is correct
52 Execution timed out 1080 ms 256 KB Time limit exceeded
53 Halted 0 ms 0 KB -