Submission #303778

# Submission time Handle Problem Language Result Execution time Memory
303778 2020-09-20T15:59:32 Z alex_velea Packing Biscuits (IOI20_biscuits) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <unordered_map>
using namespace std;
const int kMaxK = 127;

typedef long long int64;

#define DEBUG if(0)

long long count_tastiness(int64 x, std::vector<int64> a) {
    a.resize(kMaxK, 0);
    for (int i = 0; i + 1 < kMaxK; i += 1) {
        if (a[i] > x) {
            int64 carry = (a[i] - x) / 2;
            a[i + 1] += carry;
            a[i] -= carry * 2;
        }
    }

    DEBUG {
        for (int i = 0; i < 10; i += 1) {
            cerr << a[i] << '\t';
        }
        cerr << '\n';
    }

    unordered_map<int64, int64> old = { {0, 1} };

    int64 ans = 1;

    for (int i = 0; i < kMaxK; i += 1) {
        unordered_map<int64, int64> new_dp;
        for (auto& itr : old) {
            int64 carry = itr.first;
            int64 num = itr.second;

            if (carry + a[i] >= x) {
                DEBUG cerr << "Add + for " << i << '\n';
                ans += num;
                new_dp[(carry + a[i] - x) / 2] += num;
            }

            new_dp[(carry + a[i]) / 2] += num;
        }
        old = new_dp;
    }

	return ans;
}

Compilation message

biscuits.cpp:10:36: error: 'std::vector' has not been declared
   10 | long long count_tastiness(int64 x, std::vector<int64> a) {
      |                                    ^~~
biscuits.cpp:10:47: error: expected ',' or '...' before '<' token
   10 | long long count_tastiness(int64 x, std::vector<int64> a) {
      |                                               ^
biscuits.cpp: In function 'long long int count_tastiness(int64, int)':
biscuits.cpp:11:5: error: 'a' was not declared in this scope
   11 |     a.resize(kMaxK, 0);
      |     ^