Submission #980427

#TimeUsernameProblemLanguageResultExecution timeMemory
980427willychanPermutation (APIO22_perm)C++17
71.22 / 100
9 ms1372 KiB
#include "perm.h" using namespace std; std::vector<int> construct_permutation(long long k) { vector<int> s; int sum = 0; k--; for(int f=63;f>=2;f--){ while((1LL<<f)-1<=k){ s.push_back(f); k-=((1LL<<f)-1); sum+=f; } } sum+=k; for(int i=0;i<k;i++) s.push_back(1); vector<int> ans; for(auto l : s){ for(int i=sum-l+1;i<=sum;i++) ans.push_back(i-1); sum-=l; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...