Submission #1072919

#TimeUsernameProblemLanguageResultExecution timeMemory
1072919Ignut비스킷 담기 (IOI20_biscuits)C++17
12 / 100
1 ms604 KiB
// Ignut

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll count_tastiness(ll x, vector<ll> a) {
    int k = a.size();
    for (int i = 0; i < k; i ++) {
        if (a[i] > 2) {
            if (i == a.size() - 1) {
                a.push_back(0);
                k ++;
            }
            int left = (a[i] % 2 == 1 ? 1 : 2);
            a[i + 1] += (a[i] - left) / 2;
            a[i] = left;
        }
    }
    a.push_back(0);
    k ++;

    // for (int val : a) cerr << val << ' ';
    // cout << '\n';

    ll dp[k + 1][4] = {};
    dp[0][0] = 1;
    for (int i = 0; i < k; i ++) {
        for (int prev = 0; prev <= 3; prev ++) {
            ll val = a[i] + prev / 2;
            // take 1
            if (val >= 1)
                dp[i + 1][val - 1] += dp[i][prev];
            // take 0
            dp[i + 1][val] += dp[i][prev];
        }
    }

    // for (int i = 0; i <= k; i ++) {
    //     for (int v = 0; v <= 3; v ++) {
    //         cout << dp[i][v] << ' ';
    //     }
    //     cout << '\n';
    // }

    ll res = 0;
    for (int v = 0; v <= 3; v ++) res += dp[k][v];
    return res;
}

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |             if (i == a.size() - 1) {
      |                 ~~^~~~~~~~~~~~~~~
#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...