Submission #836265

# Submission time Handle Problem Language Result Execution time Memory
836265 2023-08-24T09:25:31 Z maomao90 Packing Biscuits (IOI20_biscuits) C++17
0 / 100
15 ms 396 KB
// I can do all things through Christ who strengthens me
// Philippians 4:13

#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;

#define REP(i, j, k) for (int i = j; i < (k); i++)
#define RREP(i, j, k) for (int i = j; i >= (k); i--)

template <class T>
inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005;
const int MAXK = 62;

int k;
ll x;
vll a;
unordered_map<ll, ll> dp[MAXK];

ll count_tastiness(ll _x, vll _a) {
    x = _x; a = _a;
    k = SZ(a);
    ll sm = 0;
    REP (i, 0, k) {
        sm += a[i] << i;
    }
    if (sm == 0 || k > sm) {
        return 1;
    }
    k = 64 - __builtin_clzll(sm);
    a.resize(k, 0);
    REP (i, 0, k) {
        if (a[i] < x) {
            continue;
        }
        ll ex = (a[i] - x) / 2;
        if (i + 1 == k) {
            assert(ex == 0);
            break;
        }
        a[i] -= ex * 2;
        a[i + 1] += ex;
    }
    dp[0][0] = 1;
    REP (i, 1, k + 1) {
        /*
        REP (j, 0, x + 1) {
            dp[i][j] = 0;
        }
        */
        dp[i].clear();
        for (auto [j, v] : dp[i - 1]) {
        //REP (j, 0, x + 1) {
            int ta = a[i - 1] + j;
            //dp[i][ta / 2] += dp[i - 1][j];
            dp[i][ta / 2] += v;
            if (ta >= x) {
                //dp[i][(ta - x) / 2] += dp[i - 1][j];
                dp[i][0] += v;
            }
        }
    }
    return dp[k][0];
}

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -