제출 #589512

#제출 시각아이디문제언어결과실행 시간메모리
589512LucaIliePacking Biscuits (IOI20_biscuits)C++17
9 / 100
1091 ms340 KiB
#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std;

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 );
}

컴파일 시 표준 에러 (stderr) 메시지

biscuits.cpp: In function 'long long int countSolutions(int, long long int, long long int, std::vector<long long int>&)':
biscuits.cpp:9:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     if ( b >= a.size() )
      |          ~~^~~~~~~~~~~
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:21:18: warning: unused variable 'm' [-Wunused-variable]
   21 |     long long s, m;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...