답안 #205432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
205432 2020-02-28T23:28:13 Z anonymous Bali Sculptures (APIO15_sculpture) C++14
0 / 100
5 ms 376 KB
#include<iostream>
#define MAXN 2005
#define LL long long
using namespace std;
int N, A, B, Y[MAXN];
int dp2[MAXN];
bool dp1[MAXN][MAXN];
LL bits = (1LL << 41) - 1LL, Sum[MAXN];

void case1() { //N <= 100
    for (int b = 39; b >= 0; b--) {
        bits -= (1LL << b);
        dp1[0][0]=1;
        for (int i=1; i<=N; i++) {
            for (int j=1; j<=N; j++) {
                dp1[i][j]=0;
            }
        }
        for (int k=1; k<=N; k++) {
            for (int n=1; n<=N; n++) {
                for (int j=0; j<n; j++) {
                    if (((Sum[n] - Sum[j]) | bits) == bits) {
                        dp1[n][k]|=dp1[j][k-1];
                    }
                }
            }
        }
        bool good = false;
        for (int i=A; i<=B; i++) {
            good |= dp1[N][i];
        }
        if (!good) {bits += (1LL << b);}
    }
    printf("%lld", bits);
}

void case2() { //N <= 2000
    for (int b = 39; b >= 0; b--) {
        bits -= (1LL << b);
        for (int i=1; i<=N; i++) {
            dp2[i]=1<<30;
        }
        for (int n=1; n<=N; n++) {
            for (int j=0; j<n; j++) {
                if (((Sum[n] - Sum[j]) | bits) == bits) {
                    dp2[n]=min(dp2[n], dp2[j] + 1);
                }
            }
        }
        if (dp2[N] > B) {bits += (1LL << b);}
    }
    printf("%lld", bits);
}
int main() {
    //freopen("balin.txt","r",stdin);
    scanf("%d %d %d",&N,&A,&B);
    for (int i=1; i<=N; i++) {
        scanf("%d",&Y[i]);
        Sum[i]=Sum[i-1] + Y[i];
    }
    if (A == 1) {
        case2();
    } else {
        case1();
    }
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:56: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:58:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&Y[i]);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -