Submission #1014912

#TimeUsernameProblemLanguageResultExecution timeMemory
1014912UnforgettableplPacking Biscuits (IOI20_biscuits)C++17
0 / 100
6 ms596 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 move(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 move(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 move(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 move(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]; }

Compilation message (stderr)

biscuits.cpp: In function 'std::map<long long int, long long int> right_shift(long long int, std::map<long long int, long long int>&)':
biscuits.cpp:17:13: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
   17 |  return move(ans);
      |         ~~~~^~~~~
biscuits.cpp:17:13: note: remove 'std::move' call
biscuits.cpp: In function 'std::map<long long int, long long int> left_shift(long long int, std::map<long long int, long long int>&)':
biscuits.cpp:31:13: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
   31 |  return move(ans);
      |         ~~~~^~~~~
biscuits.cpp:31:13: note: remove 'std::move' call
biscuits.cpp: In function 'std::map<long long int, long long int> collapse(std::map<long long int, long long int>&)':
biscuits.cpp:56:13: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
   56 |  return move(ans);
      |         ~~~~^~~~~
biscuits.cpp:56:13: note: remove 'std::move' call
#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...