Submission #418733

#TimeUsernameProblemLanguageResultExecution timeMemory
4187332qbingxuanPacking Biscuits (IOI20_biscuits)C++14
Compilation error
0 ms0 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;

const int maxn = 65;
map<long long, long long> dp[maxn];
long long dfs(vector<long long> &a, long long x, int i, long long carry) {
    if (i == a.size()) {
        return carry / x + 1;
    }
    if (dp[i].count(carry))
        return dp[i][carry];
    long long &res = dp[i][carry];
    carry += a[i];
    res += dfs(a, x, i+1, carry / 2); // y >> i & 1 == 0
    if (carry >= x) {
        res += dfs(a, x, i+1, (carry - x) / 2);
    }
    return res;
}
long long count_tastiness(long long x, std::vector<long long> a) {
    dp.clear();
    return dfs(a, x, 0, 0);
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int dfs(std::vector<long long int>&, long long int, int, long long int)':
biscuits.cpp:8:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     if (i == a.size()) {
      |         ~~^~~~~~~~~~~
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:22:8: error: request for member 'clear' in 'dp', which is of non-class type 'std::map<long long int, long long int> [65]'
   22 |     dp.clear();
      |        ^~~~~