Submission #1014911

#TimeUsernameProblemLanguageResultExecution timeMemory
1014911UnforgettableplPacking Biscuits (IOI20_biscuits)C++17
21 / 100
1098 ms25136 KiB
#pragma GCC optimize("Ofast","unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long const int LIMIT = 59; map<int,int> inline right_shift(int x,map<int,int> &inp){ map<int,int> ans; for(auto[a,b]:inp)ans[a+x]=b; if(!ans.empty()){ int offset = ans.begin()->second; ans.erase(ans.begin()); ans[0]=offset; } return ans; } map<int,int> inline left_shift(int x,map<int,int> &inp){ map<int,int> ans; for(auto[a,b]:inp)ans[a-x]=b; auto iter = ans.begin(); int currsum = 0; while(iter!=ans.end()){ if(iter->first>=0)break; currsum+=iter->second; iter = ans.erase(iter); } ans[0]+=currsum; return ans; } void inline add(map<int,int> &inp1,map<int,int> &inp2){ if(inp1.size()<inp2.size())swap(inp1,inp2); for(auto[a,b]:inp2){ inp1[a]+=b; if(inp1[a]==0)inp1.erase(a); } } map<int,int> inline shift(int x,map<int,int> &inp){ if(x<0)return right_shift(-x,inp); else if(0<x)return left_shift(x,inp); return inp; } map<int,int> inline collapse(map<int,int> &inp){ map<int,int> ans; for(auto[a,b]:inp)ans[(a+1ll)/2ll]+=b; auto iter = ans.begin(); while(iter!=ans.end()){ if(iter->second==0)iter=ans.erase(iter); else iter++; } return ans; } long long count_tastiness(long long x, std::vector<long long> a) { a.resize(LIMIT+1); map<int,int> curr; curr[1]=-1; curr[0]=1; for(int i=0;i<=LIMIT;i++){ map<int,int> t = shift((-a[i]),curr); map<int,int> tt = shift((-a[i]+x),curr); add(t,tt); curr = collapse(t); } return curr[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...