Submission #304966

#TimeUsernameProblemLanguageResultExecution timeMemory
304966MarcoMeijerPacking Biscuits (IOI20_biscuits)C++14
Compilation error
0 ms0 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
 
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
 
const ll MX=60, MX2=2e4+2;
 
ll x; vll a;
map<ll,ll> dp[MX];
 
void addDP(ll i, ll j, ll v) {
    if(j >= MX2) j = MX2;
    if(j < 0) return;
    dp[i][j] += v;
}
ll getDP(ll i, ll j, ll v) {
    if(j < 0) j = 0;
    if(j >= MX2) return 0;
    return dp[i][j];
}
 
ll count_tastiness(ll X, vll A) {
    x=X; a=A;
 
    while(a.size() < MX) a.pb(0);
    RE(i,MX) {
        if(a[i] >= x+2) {
            ll rem = ((a[i]-x)/2ll)*2ll;
            a[i  ] -= rem;
            a[i+1] += rem/2ll;
        }
    }
 
    // base cases
    /*RE(i,MX) dp[i].clear();
    dp[0][a[0]] += 1;
    if(a[0]-x >= 0) dp[0][a[0]-x] += 1;
 
    REP(i,1,MX) {
        FOR(p,dp[i-1]) {
            addDP(i, (p.fi+2ll*a[i])/2ll, p.se);
            addDP(i, (p.fi+2ll*a[i]-2ll*x)/2ll, p.se);
        }
    }
 
    ll ans = 0;
    FOR(p,dp[MX-1]) ans += p.se;*/

 
    RE(i,MX) RE(j,MX2) {
        dp[i][j] = 0ll;
        if(i == 0) {
            ll remaining = a[i]-j;
            if(j <= a[i])
                dp[i][j]++;
            if(j <= a[i]-x)
                dp[i][j]++;
            continue;
        }
        dp[i][j] += getDP(i-1,(j-a[i])*2ll);
        dp[i][j] += getDP(i-1,(j+x-a[i])*2ll);
    }
    
	return dp[MX-1][0];
}

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, vll)':
biscuits.cpp:78:16: warning: unused variable 'remaining' [-Wunused-variable]
   78 |             ll remaining = a[i]-j;
      |                ^~~~~~~~~
biscuits.cpp:85:43: error: too few arguments to function 'll getDP(ll, ll, ll)'
   85 |         dp[i][j] += getDP(i-1,(j-a[i])*2ll);
      |                                           ^
biscuits.cpp:41:4: note: declared here
   41 | ll getDP(ll i, ll j, ll v) {
      |    ^~~~~
biscuits.cpp:86:45: error: too few arguments to function 'll getDP(ll, ll, ll)'
   86 |         dp[i][j] += getDP(i-1,(j+x-a[i])*2ll);
      |                                             ^
biscuits.cpp:41:4: note: declared here
   41 | ll getDP(ll i, ll j, ll v) {
      |    ^~~~~