This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "biscuits.h"
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
vector<ll> b;
unordered_set<ll> vls;
void rec(int ps, ll vl){
if (ps == sz(b)){
vls.insert(vl);
return;
}
rec(ps + 1, vl);
if (b[ps] > 0) rec(ps + 1, vl + (1ll << ps));
if (b[ps] > 1) rec(ps + 1, vl + (1ll << (ps + 1)));
}
long long count_tastiness(long long x, std::vector<long long> a) {
ll ans = 1;
assert(x == 1);
int k = sz(a);
for (int sml = 0; sml < k; sml++) {
b = a;
vls.clear();
if (a[sml] > 0) {
for (int cur = sml; cur < k; cur++){
if (b[cur] == 0) continue;
if (cur + 1 < k)
b[cur + 1] += max(0ll, b[cur] - 2) / 2;
}
rec(sml, 0);
ans += sz(b);
}
if (sml + 1 < k)
a[sml + 1] += a[sml] / 2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |