Submission #1253718

#TimeUsernameProblemLanguageResultExecution timeMemory
1253718hoa208Bali Sculptures (APIO15_sculpture)C++17
0 / 100
1095 ms328 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define pa pair<ll, ll>
#define fi first
#define se second
#define bit(mask, j) ((mask >> j) & 1)
#define t_test int t;cin >> t;while(t--)
const   ll mod = 1e9 + 7;
const   ll INF = 1e18;
inline  void adm(ll &x){if(x>=mod)x%=mod;else if(x<0)x+=mod;}
//--------------------------------------------------------------------

const ll N = 103;
ll w[N], dp[N][N], s[N];
ll get_sum(ll i, ll j) {
    return s[j] - s[i - 1];
}
void hbmt() {
    ll n, a, b;
    cin >> n >> a >> b;
    FOR(i, 1, n) {
        cin >> w[i];
        s[i] = s[i - 1] + w[i];
    }
    ll LG = __lg(s[n]);
    ll mask = 0;
    FORD(j, LG, 0) {
        memset(dp, 0, sizeof dp);
        dp[0][0] = 1;
        FOR(i, 1, n) {
            FOR(y, 1, b) {
                FOR(u, 0, i - 1) {
                    if(dp[u][y - 1] == 1) {
                        ll x = mask | get_sum(u + 1, i);
                        bool ok = true;
                        FORD(v, LG, j) {
                            if(bit(mask, v) != bit(x, v)) {
                                ok = false;
                                break;
                            }
                        }
                        if(ok) {
                            dp[i][y] = 1;
                        }
                    }
                }
            }
        }
        bool ok = false;
        FOR(y, a, b) {
            if(dp[n][y]) {
                ok = true;
                break;
            }
        }
        if(!ok) mask ^= (1LL << j);
    }
    cout << mask;
}

int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    
    if(fopen("hbmt.inp", "r")) {
        freopen("hbmt.inp", "r", stdin);
        freopen("hbmt.out", "w", stdout);
    }
    
    // t_test 
    hbmt();
    return 0;
}

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:70:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |         freopen("hbmt.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen("hbmt.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...