Submission #589511

# Submission time Handle Problem Language Result Execution time Memory
589511 2022-07-04T19:26:40 Z LucaIlie Packing Biscuits (IOI20_biscuits) C++17
Compilation error
0 ms 0 KB
#include "biscuits.h"

long long countSolutions( int b, long long s, long long x, vector <long long> &a ) {
    int solutions;

    if ( b >= a.size() )
        return 1;

    solutions = countSolutions( b + 1, (a[b] + s ) / 2, x, a );
    if ( a[b] + s >= x )
        solutions += countSolutions( b + 1, (a[b] + s - x) / 2, x, a );

    return solutions;
}

long long count_tastiness( long long x, vector <long long> a ) {
    const int k = 60;
    long long s, m;
    unordered_map <long, long long> dp[k];

    a.resize( k );

    s = 0;
    for ( int b = 0; b < k; b++ ) {
        a[b] += s;
        if ( a[b] > x ) {
            s = a[b] - x;
            a[b] = x + s % 2;
            s /= 2;
        } else
            s = 0;
    }

    /*dp[0][a[0]] = 1;
    if ( a[0] - x >= 0 )
        dp[0][a[0] - x] = 1;
    for ( int b = 1; b < k; b++ ) {
        for ( auto p: dp[b - 1] ) {
            s = p.first;
            m = p.second;
            dp[b][s / 2 + a[b]] += m;
            if ( s / 2 + a[b] - x >= 0 )
                dp[b][s / 2 + a[b] - x] += m;
        }
    }

    m = 0;
    for ( auto p: dp[k - 1] )
        m += p.second;
    return m;*/
    return countSolutions( 0, 0, x, a );
}

Compilation message

biscuits.cpp:3:60: error: 'vector' has not been declared
    3 | long long countSolutions( int b, long long s, long long x, vector <long long> &a ) {
      |                                                            ^~~~~~
biscuits.cpp:3:67: error: expected ',' or '...' before '<' token
    3 | long long countSolutions( int b, long long s, long long x, vector <long long> &a ) {
      |                                                                   ^
biscuits.cpp: In function 'long long int countSolutions(int, long long int, long long int, int)':
biscuits.cpp:6:15: error: 'a' was not declared in this scope
    6 |     if ( b >= a.size() )
      |               ^
biscuits.cpp:9:41: error: 'a' was not declared in this scope
    9 |     solutions = countSolutions( b + 1, (a[b] + s ) / 2, x, a );
      |                                         ^
biscuits.cpp: At global scope:
biscuits.cpp:16:41: error: 'vector' has not been declared
   16 | long long count_tastiness( long long x, vector <long long> a ) {
      |                                         ^~~~~~
biscuits.cpp:16:48: error: expected ',' or '...' before '<' token
   16 | long long count_tastiness( long long x, vector <long long> a ) {
      |                                                ^
biscuits.cpp: In function 'long long int count_tastiness(long long int, int)':
biscuits.cpp:19:5: error: 'unordered_map' was not declared in this scope
   19 |     unordered_map <long, long long> dp[k];
      |     ^~~~~~~~~~~~~
biscuits.cpp:19:20: error: expected primary-expression before 'long'
   19 |     unordered_map <long, long long> dp[k];
      |                    ^~~~
biscuits.cpp:21:5: error: 'a' was not declared in this scope
   21 |     a.resize( k );
      |     ^
biscuits.cpp:18:18: warning: unused variable 'm' [-Wunused-variable]
   18 |     long long s, m;
      |                  ^