(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #490305

#TimeUsernameProblemLanguageResultExecution timeMemory
490305mraronPacking Biscuits (IOI20_biscuits)C++14
100 / 100
945 ms1608 KiB
#include "biscuits.h" #include <iostream> #include <unordered_map> #include <map> #include <utility> #include <functional> #include <cassert> #include <set> #include <random> using namespace std; using ll = long long ; ll x; vector<ll> a; map<ll, ll> dp[61]; mt19937 rnd(453); ll calc(ll rem, ll i) { if(i>=(int)a.size()) return 1LL<<(rem/x); auto it=dp[i].lower_bound(rem); if(it!=dp[i].end() && it->first==rem) return dp[i][rem]; if(it!=dp[i].end() && it!=dp[i].begin()) { if(it->second==prev(it)->second) { return it->second; } } ll orig=rem; if(i<(int)a.size() || rem>=x) { if(i<(int)a.size()) { rem+=a[i]; } ll ans=0; if(rem>=x) { if(i&1) { ans+=calc(rem/2, i+1); ans+=calc((rem-x)/2, i+1); }else { ans+=calc((rem-x)/2, i+1); ans+=calc(rem/2, i+1); } }else { ans+=calc(rem/2, i+1); } return dp[i][orig]=ans; }else { return 1; } } ll count_tastiness(ll x_, vector<ll> a_) { a=a_; x=x_; a.resize(60); for(int i=0;i<60;++i) { if(a[i]>=x+2) { ll diff=a[i]-(x+1); a[i]-=(diff+1)/2*2; a[i+1]+=(diff+1)/2; } } while(a.back()==0) a.pop_back(); for(auto& i:dp) i.clear(); return calc(0, 0); }
#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...