Submission #303335

#TimeUsernameProblemLanguageResultExecution timeMemory
303335ElegiaPacking Biscuits (IOI20_biscuits)C++17
Compilation error
0 ms0 KiB
#include "biscuits.h" #include <unordered_map> using namespace std; using ll = long long; ll count_tastiness(ll x, vector<ll> a) { a.resize(61); vector<unordered_map<ll, ll>> dp(61); function<ll(int, ll)> dfs = [&](int k, ll v) { if (k == 60) return 1LL; if (dp[k].count(v)) return dp[k][v]; ll ret = dfs(k + 1, (v + a[k]) / 2); if (v + a[k] >= x) ret += dfs(k + 1, (v + a[k] - x) / 2); return dp[k][v] = ret; }; return dfs(0, 0); }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:12:2: error: 'function' was not declared in this scope
   12 |  function<ll(int, ll)> dfs = [&](int k, ll v) {
      |  ^~~~~~~~
biscuits.cpp:4:1: note: 'std::function' is defined in header '<functional>'; did you forget to '#include <functional>'?
    3 | #include <unordered_map>
  +++ |+#include <functional>
    4 | 
biscuits.cpp:12:21: error: expression list treated as compound expression in functional cast [-fpermissive]
   12 |  function<ll(int, ll)> dfs = [&](int k, ll v) {
      |                     ^
biscuits.cpp:12:13: error: expected primary-expression before '(' token
   12 |  function<ll(int, ll)> dfs = [&](int k, ll v) {
      |             ^
biscuits.cpp:12:14: error: expected primary-expression before 'int'
   12 |  function<ll(int, ll)> dfs = [&](int k, ll v) {
      |              ^~~
biscuits.cpp:12:21: error: expected primary-expression before ')' token
   12 |  function<ll(int, ll)> dfs = [&](int k, ll v) {
      |                     ^
biscuits.cpp:12:24: error: 'dfs' was not declared in this scope
   12 |  function<ll(int, ll)> dfs = [&](int k, ll v) {
      |                        ^~~