답안 #729387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729387 2023-04-24T02:14:21 Z hoainiem Bali Sculptures (APIO15_sculpture) C++14
0 / 100
3 ms 340 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define lc id<<1
#define rc id<<1^1
const long long inf = 1e18;
using namespace std;
typedef pair<int, int> pii;
int n, l, r;
int a[2008], p[2008][38], orr[2008][2008];
long long ans = inf, f[2008];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    freopen("file.inp", "r", stdin);
    freopen("file.out", "w", stdout);
    cin >> n >> l >> r;
    fill(p[0], p[0] + 30, 0);
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        for (int j = i; j <= n; j++)
            orr[i][j] = orr[i][j - 1] | a[j];
        for (int j = 0; j < 30; j++)
            p[i][j] = ((a[i] >> j) & 1) ? i : p[i - 1][j];
        f[i] = a[i];
    }
    f[0] = 0;
    if (l <= 1 && 1 <= r)
        ans = min(ans, f[n]);
    for (int j = 2; j <= r; j++){
        for (int i = n; i >= 0; i--)
            if (i < j)
                f[i] = inf;
            else{
                f[i] = inf;
                for (int bit = 0; bit < 30; bit++)
                    if (p[i][bit] > 0)
                        f[i] = min(f[i], f[p[i][bit] - 1] + orr[p[i][bit]][i]);
            }
        if (j >= l)
            ans = min(ans, f[n]);
    }
    cout << ans;
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("file.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("file.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -