이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
#define ll long long int
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define fori(i,n) for(int i = 0; i < int(n); i++)
void simplify(ll x, vll& a) {
while(a.size() < 61) a.push_back(0);
ll extra = 0;
for(ll &i : a) {
extra += i;
i = min(x, extra);
extra -= i;
if(extra&1) i++;
extra /= 2;
}
}
unordered_map<ll, ll> dp[60];
ll recurse(const int index,const ll x, vll& a) {
if(index >= 60) return 1;
if(dp[index].count(a[index])) return dp[index][a[index]];
ll ans = 0;
ll extra = a[index] / 2;
a[index+1] += extra;
ans += recurse(index+1, x, a);
a[index+1] -= extra;
if(a[index] >= x) {
extra = (a[index] - x) / 2;
a[index+1] += extra;
ans += recurse(index+1, x, a);
a[index+1] -= extra;
}
return dp[index][a[index]] = ans;
}
ll count_tastiness(ll x, vll a) {
simplify(x, a);
fori(i,60) dp[i].clear();
return recurse(0, x, a);
}
# | 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... |