답안 #585788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585788 2022-06-29T10:50:33 Z LucaIlie 비스킷 담기 (IOI20_biscuits) C++17
0 / 100
1000 ms 26036 KB
#include "biscuits.h"
#include <bits/stdc++.h>

#define MAX_K 60

using namespace std;

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

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

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

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:15:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for ( int b = 0; b < a.size() || s > 0; b++ ) {
      |                      ~~^~~~~~~~~~
biscuits.cpp:16:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         if ( b >= a.size() )
      |              ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 26036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 20684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -