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>
using namespace std;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
using matrix = vector<vector<T>>;
const int MAXN = 123;
long long count_tastiness(long long x, std::vector<long long> a) {
vector<ll> ct(MAXN);
for(int i = 0; i < a.size(); i++)
ct[i] = a[i];
vector<map<ll,ll>> state(MAXN);
auto solve=[&](int id, ll extra, auto solve)->ll{
if(id == MAXN)
return 1;
if(state[id].count(extra))
return state[id][extra];
ll resp = solve(id+1,(ct[id]+extra)/2,solve);
if(ct[id]+extra >=x)
resp+=solve(id+1,(ct[id]+extra-x)/2,solve);
state[id][extra] = resp;
return resp;
};
return solve(0,0,solve);
}
Compilation message (stderr)
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int i = 0; i < a.size(); i++)
| ~~^~~~~~~~~~
# | 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... |