Submission #739026

# Submission time Handle Problem Language Result Execution time Memory
739026 2023-05-09T18:53:49 Z BidoTeima Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 340 KB
/*
ID: BidoTeima
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
void moo(string filename);
void ACPLS(string str = "")
{
    if(str=="NOF")return;
    if(str.size() && str != "IIOT")
        moo(str);
    else if(str != "IIOT"){
#ifndef ONLINE_JUDGE
        freopen("output.txt", "w", stdout);
        freopen("input.txt", "r", stdin);
#endif
    }
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void moo(string fileName){
    freopen((fileName+".in").c_str(),"r",stdin);
    freopen((fileName+".out").c_str(),"w",stdout);
}
#define tcccc         \
    int tttttt/*,subtask*/;    \
    cin >> tttttt/* >> subtask*/; \
    while (tttttt--)/*end
*/ 
int main()
{    
    //ACPLS("");     
    int n,a,b;
    cin>>n>>a>>b;
    ll arr[n];
    for(int i = 0; i < n; i++){
        cin>>arr[i];
        if(i) arr[i] += arr[i - 1];
    }
    auto sum = [&](int l, int r){
        if(!l) return arr[r];
        return arr[r] - arr[l - 1];
    };
    ll dp[n][n][b]{};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < b; k++){
                dp[i][j][k] = 1e15;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int k = 0; k + 1 < b; k++){
        for(int j = 0; j + 1 < n; j++){
            for(int i = 0; i <= j; i++){ 
                dp[i][j + 1][b - 1] = min(dp[i][j + 1][b - 1], dp[i][j][b - 1]);
                dp[i][j + 1][k] = min(dp[i][j + 1][k], dp[i][j][k]);
                dp[j + 1][j + 1][k + 1] = min(dp[j + 1][j + 1][k + 1], dp[i][j][k] | sum(i, j));
            } 
        }
    }
    ll ans = 1e18;
    for(int i = 0; i < n; i++){
        for(int k = a - 1; k < b; k++){
            //cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
            ans = min(ans, dp[i][n - 1][k] | sum(i, n - 1));
        }
    }
    cout << ans;
}

Compilation message

sculpture.cpp: In function 'void ACPLS(std::string)':
sculpture.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp: In function 'void moo(std::string)':
sculpture.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((fileName+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((fileName+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -